@gadmin2n/cli 0.0.108 → 0.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/update.action.js +36 -2
- package/package.json +2 -2
package/actions/update.action.js
CHANGED
|
@@ -17,6 +17,7 @@ const path = require("path");
|
|
|
17
17
|
const inquirer = require("inquirer");
|
|
18
18
|
const child_process_1 = require("child_process");
|
|
19
19
|
const abstract_action_1 = require("./abstract.action");
|
|
20
|
+
const self_update_action_1 = require("./self-update.action");
|
|
20
21
|
const version_check_1 = require("../lib/version-check");
|
|
21
22
|
const merge3way_1 = require("../lib/template-merge/merge3way");
|
|
22
23
|
const binary_detect_1 = require("../lib/template-merge/binary-detect");
|
|
@@ -664,7 +665,7 @@ function unifiedDiffSimple(a, b) {
|
|
|
664
665
|
* ------------------------------------------------------------------ */
|
|
665
666
|
class UpdateAction extends abstract_action_1.AbstractAction {
|
|
666
667
|
handle(inputs, options) {
|
|
667
|
-
var _a, _b;
|
|
668
|
+
var _a, _b, _c;
|
|
668
669
|
return __awaiter(this, void 0, void 0, function* () {
|
|
669
670
|
const subcommand = (_a = inputs.find((i) => i.name === 'subcommand')) === null || _a === void 0 ? void 0 : _a.value;
|
|
670
671
|
if (subcommand && subcommand !== 'update' && subcommand !== 'diff' && subcommand !== 'status') {
|
|
@@ -687,14 +688,47 @@ class UpdateAction extends abstract_action_1.AbstractAction {
|
|
|
687
688
|
// hard 1.5s timeout, never blocks. Prints a yellow banner if outdated.
|
|
688
689
|
const versionCheckEnabled = ((_b = options.find((o) => o.name === 'version-check')) === null || _b === void 0 ? void 0 : _b.value) !==
|
|
689
690
|
false;
|
|
691
|
+
const autoYes = !!((_c = options.find((o) => o.name === 'yes')) === null || _c === void 0 ? void 0 : _c.value);
|
|
690
692
|
if (versionCheckEnabled) {
|
|
691
693
|
try {
|
|
692
694
|
const info = yield (0, version_check_1.checkVersion)(1500);
|
|
693
695
|
if (info && (0, version_check_1.compareVersions)(info.installed, info.latest) < 0) {
|
|
694
696
|
(0, version_check_1.printOutdatedWarning)(info);
|
|
697
|
+
// For the main `gadmin2 update` (no subcommand), prompt the user to
|
|
698
|
+
// run `gadmin2 self-update` first. The current process is still on
|
|
699
|
+
// the old CLI binary, so silently continuing risks running the old
|
|
700
|
+
// pipeline against fresh templates. We therefore force a choice:
|
|
701
|
+
// - run self-update now → upgrade then exit, ask user to re-run.
|
|
702
|
+
// - cancel → exit without doing anything.
|
|
703
|
+
// In --yes / non-interactive mode, we keep the legacy behaviour:
|
|
704
|
+
// the warning is printed and the update proceeds. `diff` and
|
|
705
|
+
// `status` subcommands are read-only and skip this prompt entirely.
|
|
706
|
+
const isMainUpdate = !subcommand || subcommand === 'update';
|
|
707
|
+
if (isMainUpdate && !autoYes) {
|
|
708
|
+
const { proceedSelfUpdate } = yield inquirer.prompt([
|
|
709
|
+
{
|
|
710
|
+
type: 'confirm',
|
|
711
|
+
name: 'proceedSelfUpdate',
|
|
712
|
+
message: 'A newer gadmin2 CLI version is available. ' +
|
|
713
|
+
'Run `gadmin2 self-update` first before updating the project?',
|
|
714
|
+
default: true,
|
|
715
|
+
},
|
|
716
|
+
]);
|
|
717
|
+
if (proceedSelfUpdate) {
|
|
718
|
+
const selfUpdate = new self_update_action_1.SelfUpdateAction();
|
|
719
|
+
yield selfUpdate.handle([], []);
|
|
720
|
+
console.info(chalk.cyan('\n→ Self-update finished. Please re-run `gadmin2 update` so the new CLI binary drives the merge.\n'));
|
|
721
|
+
process.exit(0);
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
console.info(chalk.gray('\nCancelled — exiting without running update. ' +
|
|
725
|
+
'Re-run when you are ready (or pass `--no-version-check` / `--yes` to bypass this prompt).\n'));
|
|
726
|
+
process.exit(0);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
695
729
|
}
|
|
696
730
|
}
|
|
697
|
-
catch (
|
|
731
|
+
catch (_d) {
|
|
698
732
|
// never let the version check break update
|
|
699
733
|
}
|
|
700
734
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadmin2n/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.110",
|
|
4
4
|
"description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@angular-devkit/core": "13.3.2",
|
|
48
48
|
"@angular-devkit/schematics": "13.3.2",
|
|
49
49
|
"@angular-devkit/schematics-cli": "13.3.2",
|
|
50
|
-
"@gadmin2n/schematics": "^0.0.
|
|
50
|
+
"@gadmin2n/schematics": "^0.0.90",
|
|
51
51
|
"abc": "^0.6.1",
|
|
52
52
|
"chalk": "3.0.0",
|
|
53
53
|
"chokidar": "3.5.3",
|