mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
update package.json on plugin postinstall
This is required in order to fix autocomplete of intellij.
This commit is contained in:
42
scm-ui/ui-plugins/bin/ui-plugins.js
Normal file
42
scm-ui/ui-plugins/bin/ui-plugins.js
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
/* eslint-disable no-console */
|
||||
const { spawnSync } = require("child_process");
|
||||
|
||||
const commands = ["postinstall"];
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
const commandIndex = args.findIndex(arg => {
|
||||
return commands.includes(arg);
|
||||
});
|
||||
|
||||
const command = commandIndex === -1 ? args[0] : args[commandIndex];
|
||||
const nodeArgs = commandIndex > 0 ? args.slice(0, commandIndex) : [];
|
||||
|
||||
if (commands.includes(command)) {
|
||||
const result = spawnSync(
|
||||
"node",
|
||||
nodeArgs.concat(require.resolve("../src/commands/" + command)).concat(args.slice(commandIndex + 1)),
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
if (result.signal) {
|
||||
if (result.signal === "SIGKILL") {
|
||||
console.log(
|
||||
"The build failed because the process exited too early. " +
|
||||
"This probably means the system ran out of memory or someone called " +
|
||||
"`kill -9` on the process."
|
||||
);
|
||||
} else if (result.signal === "SIGTERM") {
|
||||
console.log(
|
||||
"The build failed because the process exited too early. " +
|
||||
"Someone might have called `kill` or `killall`, or the system could " +
|
||||
"be shutting down."
|
||||
);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(result.status);
|
||||
} else {
|
||||
console.log(`Unknown script "${command}".`);
|
||||
console.log("Perhaps you need to update ui-plugins?");
|
||||
}
|
||||
@@ -1,15 +1,28 @@
|
||||
{
|
||||
"name": "@scm-manager/ui-plugins",
|
||||
"version": "2.0.0-SNAPSHOT",
|
||||
"version": "2.0.0-11",
|
||||
"license": "BSD-3-Clause",
|
||||
"bin": {
|
||||
"ui-plugins": "./bin/ui-plugins.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@scm-manager/ui-components": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-extensions": "^2.0.0-SNAPSHOT",
|
||||
"classnames": "^2.2.6",
|
||||
"query-string": "^5.0.1",
|
||||
"react": "^16.10.2",
|
||||
"react-i18next": "^10.13.1",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"redux": "^4.0.0",
|
||||
"styled-components": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scm-manager/babel-preset": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/eslint-config": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/jest-preset": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/prettier-config": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/tsconfig": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-components": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-extensions": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-scripts": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-tests": "^2.0.0-SNAPSHOT",
|
||||
"@scm-manager/ui-types": "^2.0.0-SNAPSHOT",
|
||||
@@ -23,15 +36,7 @@
|
||||
"@types/react-redux": "5.0.7",
|
||||
"@types/react-router-dom": "^5.1.0",
|
||||
"@types/styled-components": "^4.1.19",
|
||||
"classnames": "^2.2.6",
|
||||
"jest": "^24.9.0",
|
||||
"query-string": "^5.0.1",
|
||||
"react": "^16.10.2",
|
||||
"react-i18next": "^10.13.1",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"redux": "^4.0.0",
|
||||
"styled-components": "^4.4.0"
|
||||
"jest": "^24.9.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
49
scm-ui/ui-plugins/src/commands/postinstall.js
Normal file
49
scm-ui/ui-plugins/src/commands/postinstall.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/* eslint-disable no-console */
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const { spawnSync } = require("child_process");
|
||||
|
||||
const packageJsonPath = path.join(process.cwd(), "package.json");
|
||||
const packageJSON = JSON.parse(fs.readFileSync(packageJsonPath, "UTF-8"));
|
||||
|
||||
const reference = require("../../package.json");
|
||||
|
||||
const sync = (left, right, key) => {
|
||||
if (!right[key]) {
|
||||
right[key] = {};
|
||||
}
|
||||
|
||||
let changed = false;
|
||||
|
||||
const keys = Object.keys(left[key]);
|
||||
keys.forEach(name => {
|
||||
if (right[key][name] !== left[key][name]) {
|
||||
console.log(name, "has changed from", right[key][name], "to", left[key][name]);
|
||||
right[key][name] = left[key][name];
|
||||
changed = true;
|
||||
}
|
||||
});
|
||||
|
||||
return changed;
|
||||
};
|
||||
|
||||
const update = () => {
|
||||
let dep = sync(reference, packageJSON, "dependencies");
|
||||
let devDep = sync(reference, packageJSON, "devDependencies");
|
||||
return dep || devDep;
|
||||
};
|
||||
|
||||
if (update()) {
|
||||
console.log("dependencies changed, install new dependencies");
|
||||
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJSON, null, " "), { encoding: "UTF-8" });
|
||||
|
||||
const result = spawnSync("yarn", ["install"], { stdio: "inherit" });
|
||||
if (result.error) {
|
||||
console.log("could not start yarn command:", result.error);
|
||||
process.exit(2);
|
||||
} else if (result.status !== 0) {
|
||||
console.log("yarn process ends with status code:", result.status);
|
||||
process.exit(3);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
/* eslint-disable no-console */
|
||||
const { spawnSync } = require("child_process");
|
||||
|
||||
const commands = ["plugin", "plugin-watch", "publish", "version"];
|
||||
@@ -15,9 +16,7 @@ const nodeArgs = commandIndex > 0 ? args.slice(0, commandIndex) : [];
|
||||
if (commands.includes(command)) {
|
||||
const result = spawnSync(
|
||||
"node",
|
||||
nodeArgs
|
||||
.concat(require.resolve("../src/commands/" + command))
|
||||
.concat(args.slice(commandIndex + 1)),
|
||||
nodeArgs.concat(require.resolve("../src/commands/" + command)).concat(args.slice(commandIndex + 1)),
|
||||
{ stdio: "inherit" }
|
||||
);
|
||||
if (result.signal) {
|
||||
@@ -38,9 +37,6 @@ if (commands.includes(command)) {
|
||||
}
|
||||
process.exit(result.status);
|
||||
} else {
|
||||
console.log("Unknown script \"" + command + "\".");
|
||||
console.log("Perhaps you need to update react-scripts?");
|
||||
console.log(
|
||||
"See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases"
|
||||
);
|
||||
console.log(`Unknown script "${command}".`);
|
||||
console.log("Perhaps you need to update ui-scripts?");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user