@gadmin2n/cli 0.0.164 → 0.0.165
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 +19 -52
- package/package.json +2 -2
package/actions/update.action.js
CHANGED
|
@@ -17,7 +17,6 @@ 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");
|
|
21
20
|
const version_check_1 = require("../lib/version-check");
|
|
22
21
|
const executable_paths_1 = require("../lib/executable-paths");
|
|
23
22
|
const merge3way_1 = require("../lib/template-merge/merge3way");
|
|
@@ -720,7 +719,7 @@ function unifiedDiffSimple(a, b) {
|
|
|
720
719
|
* ------------------------------------------------------------------ */
|
|
721
720
|
class UpdateAction extends abstract_action_1.AbstractAction {
|
|
722
721
|
handle(inputs, options) {
|
|
723
|
-
var _a, _b
|
|
722
|
+
var _a, _b;
|
|
724
723
|
return __awaiter(this, void 0, void 0, function* () {
|
|
725
724
|
const subcommand = (_a = inputs.find((i) => i.name === 'subcommand')) === null || _a === void 0 ? void 0 : _a.value;
|
|
726
725
|
if (subcommand && subcommand !== 'update' && subcommand !== 'diff' && subcommand !== 'status') {
|
|
@@ -739,63 +738,31 @@ class UpdateAction extends abstract_action_1.AbstractAction {
|
|
|
739
738
|
'Run this command from the project root created by `gadmin2 n <name>`.\n'));
|
|
740
739
|
process.exit(1);
|
|
741
740
|
}
|
|
742
|
-
//
|
|
743
|
-
// hard 1.5s timeout, never blocks. Prints a yellow banner if outdated.
|
|
741
|
+
// Kick off version check in background — never blocks the main path.
|
|
744
742
|
const versionCheckEnabled = ((_b = options.find((o) => o.name === 'version-check')) === null || _b === void 0 ? void 0 : _b.value) !==
|
|
745
743
|
false;
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
const info = yield (0, version_check_1.checkVersion)(1500);
|
|
750
|
-
if (info && (0, version_check_1.compareVersions)(info.installed, info.latest) < 0) {
|
|
751
|
-
(0, version_check_1.printOutdatedWarning)(info);
|
|
752
|
-
// For the main `gadmin2 update` (no subcommand), prompt the user to
|
|
753
|
-
// run `gadmin2 self-update` first. The current process is still on
|
|
754
|
-
// the old CLI binary, so silently continuing risks running the old
|
|
755
|
-
// pipeline against fresh templates. We therefore force a choice:
|
|
756
|
-
// - run self-update now → upgrade then exit, ask user to re-run.
|
|
757
|
-
// - cancel → exit without doing anything.
|
|
758
|
-
// In --yes / non-interactive mode, we keep the legacy behaviour:
|
|
759
|
-
// the warning is printed and the update proceeds. `diff` and
|
|
760
|
-
// `status` subcommands are read-only and skip this prompt entirely.
|
|
761
|
-
const isMainUpdate = !subcommand || subcommand === 'update';
|
|
762
|
-
if (isMainUpdate && !autoYes) {
|
|
763
|
-
const { proceedSelfUpdate } = yield inquirer.prompt([
|
|
764
|
-
{
|
|
765
|
-
type: 'confirm',
|
|
766
|
-
name: 'proceedSelfUpdate',
|
|
767
|
-
message: 'A newer gadmin2 CLI version is available. ' +
|
|
768
|
-
'Run `gadmin2 self-update` first before updating the project?',
|
|
769
|
-
default: true,
|
|
770
|
-
},
|
|
771
|
-
]);
|
|
772
|
-
if (proceedSelfUpdate) {
|
|
773
|
-
const selfUpdate = new self_update_action_1.SelfUpdateAction();
|
|
774
|
-
yield selfUpdate.handle([], []);
|
|
775
|
-
console.info(chalk.cyan('\n→ Self-update finished. Please re-run `gadmin2 update` so the new CLI binary drives the merge.\n'));
|
|
776
|
-
process.exit(0);
|
|
777
|
-
}
|
|
778
|
-
else {
|
|
779
|
-
console.info(chalk.gray('\nCancelled — exiting without running update. ' +
|
|
780
|
-
'Re-run when you are ready (or pass `--no-version-check` / `--yes` to bypass this prompt).\n'));
|
|
781
|
-
process.exit(0);
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
catch (_d) {
|
|
787
|
-
// never let the version check break update
|
|
788
|
-
}
|
|
789
|
-
}
|
|
744
|
+
const versionCheckPromise = versionCheckEnabled
|
|
745
|
+
? (0, version_check_1.checkVersion)(3000).catch(() => null)
|
|
746
|
+
: Promise.resolve(null);
|
|
790
747
|
if (subcommand === 'status') {
|
|
791
748
|
yield this.handleStatus();
|
|
792
|
-
return;
|
|
793
749
|
}
|
|
794
|
-
if (subcommand === 'diff') {
|
|
750
|
+
else if (subcommand === 'diff') {
|
|
795
751
|
yield this.handleDiff(options);
|
|
796
|
-
return;
|
|
797
752
|
}
|
|
798
|
-
|
|
753
|
+
else {
|
|
754
|
+
yield this.handleUpdate(options);
|
|
755
|
+
}
|
|
756
|
+
// Print outdated warning at the very end — non-blocking, never fatal.
|
|
757
|
+
try {
|
|
758
|
+
const info = yield versionCheckPromise;
|
|
759
|
+
if (info && (0, version_check_1.compareVersions)(info.installed, info.latest) < 0) {
|
|
760
|
+
(0, version_check_1.printOutdatedWarning)(info);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
catch (_c) {
|
|
764
|
+
// never let the version check affect exit code
|
|
765
|
+
}
|
|
799
766
|
});
|
|
800
767
|
}
|
|
801
768
|
handleDiff(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadmin2n/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.165",
|
|
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.133",
|
|
51
51
|
"abc": "^0.6.1",
|
|
52
52
|
"chalk": "3.0.0",
|
|
53
53
|
"chokidar": "3.5.3",
|