@gluhar/cli 2.1.0 → 2.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gluhar/cli",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "Gluhar cli commands and scripts",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -43,5 +43,5 @@
43
43
  "tsconfig-paths": "^4.2.0",
44
44
  "typescript": "^5.5.4"
45
45
  },
46
- "gitHead": "0a8a79da3978f88f2bf27892f00b037a88da1987"
46
+ "gitHead": "1084e6d98d5bce44553a0c7a3c32affe4c16287d"
47
47
  }
package/src/index.js CHANGED
@@ -10,7 +10,7 @@ const commands_1 = __importDefault(require("./commands"));
10
10
  const preAction_1 = require("./preAction");
11
11
  commander_1.program
12
12
  .name(constants_1.PROGRAM_NAME)
13
- .description("A collection of commands and scripts for helping running, building, deploying and assisting in developing with Gluhar UI, Vue, Nuxt, Tailwind & Sanity.")
13
+ .description("A collection of commands and scripts for helping running, building, deploying and assisting in developing with Gluhar, Vue, Nuxt, Tailwind & Sanity.")
14
14
  .version(constants_1.VERSION, "-v, --version", "Output the version number.")
15
15
  .helpOption("-h, --help", "Display help for a command.")
16
16
  .option("-l, --log-level <level>", "Set log level.", "info")
@@ -1,3 +1,3 @@
1
1
  import type { Command } from "commander";
2
- export declare const preAction: (rootCmd: Command, actionCmd: Command) => void;
2
+ export declare const preAction: (rootCmd: Command, actionCmd: Command) => Promise<void>;
3
3
  //# sourceMappingURL=preAction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8CzC,eAAO,MAAM,SAAS,YAAa,OAAO,aAAa,OAAO,SAiB7D,CAAC"}
1
+ {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6DzC,eAAO,MAAM,SAAS,YAAmB,OAAO,aAAa,OAAO,kBAoBnE,CAAC"}
package/src/preAction.js CHANGED
@@ -36,12 +36,25 @@ const logCli = (actionCmd) => {
36
36
  log.verbose("options:", getOptions(actionCmd));
37
37
  log.verbose("cwd:", process.cwd());
38
38
  };
39
- const preAction = (rootCmd, actionCmd) => {
39
+ const checkCliVersion = async () => {
40
+ const latestVersion = (0, cmd_1.getCmdOutput)("npm show @gluhar/cli version");
41
+ // Version is up to date
42
+ if (latestVersion === constants_1.VERSION)
43
+ return;
44
+ // Version is old, ask to install latest
45
+ const installLatest = await (0, utils_1.confirmQuestion)(`There is a newer version of the gluhar/cli available (v${latestVersion}). \nDo you want to install it now? (npm i -g @gluhar/cli)`);
46
+ if (installLatest) {
47
+ (0, cmd_1.executeCmd)("npm i -g @gluhar/cli@latest");
48
+ }
49
+ };
50
+ const preAction = async (rootCmd, actionCmd) => {
40
51
  // setup logging before loadConfig, so we can get logging from loadConfig
41
52
  setup(rootCmd, actionCmd);
42
53
  const { cwd: initCwd } = getOptions(rootCmd);
43
54
  if (initCwd)
44
55
  cmd_1.cmd.cd(initCwd);
56
+ // Check for newer cli version
57
+ await checkCliVersion();
45
58
  // loadConfig(rootCmd, actionCmd);
46
59
  const { cwd: newCwd } = getOptions(rootCmd);
47
60
  if (newCwd && newCwd !== initCwd)
@@ -1,5 +1,5 @@
1
1
  export interface ConfirmAnswer {
2
2
  confirm: boolean;
3
3
  }
4
- export declare const confirmQuestion: (message: string, yes: boolean) => Promise<boolean>;
4
+ export declare const confirmQuestion: (message: string, yes?: boolean) => Promise<boolean>;
5
5
  //# sourceMappingURL=inquirer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inquirer.d.ts","sourceRoot":"","sources":["../../../src/utils/inquirer.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,YAAmB,MAAM,OAAO,OAAO,qBAalE,CAAC"}
1
+ {"version":3,"file":"inquirer.d.ts","sourceRoot":"","sources":["../../../src/utils/inquirer.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,YAAmB,MAAM,QAAQ,OAAO,qBAanE,CAAC"}
@@ -11,8 +11,8 @@ const confirmQuestion = async (message, yes) => {
11
11
  }
12
12
  const answer = await inquirer_1.default.prompt([
13
13
  {
14
- name: 'confirm',
15
- type: 'confirm',
14
+ name: "confirm",
15
+ type: "confirm",
16
16
  message,
17
17
  },
18
18
  ]);