@gluhar/cli 2.0.0 → 2.2.0

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.0.0",
3
+ "version": "2.2.0",
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": "7d827f45588677797fbee4ab19c77ed5ef3d3d0c"
46
+ "gitHead": "812cd4e9c210817ad607720435fed962d18b8688"
47
47
  }
@@ -1,6 +1,7 @@
1
1
  export declare const generateTypes: readonly ["project", "package", "command"];
2
2
  export type GenerateType = (typeof generateTypes)[number];
3
3
  export interface GenerateOptions {
4
+ starterBranch?: string;
4
5
  noRepo?: boolean;
5
6
  keepHistory?: boolean;
6
7
  yes: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateOptions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,4CAA6C,CAAC;AACxE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;CACd"}
1
+ {"version":3,"file":"GenerateOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/GenerateOptions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,4CAA6C,CAAC;AACxE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;CACd"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateProject.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/generateProject.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAO,MAAM,eAAe,SACpB,MAAM,OACP,MAAM,WACF,eAAe,kBAwGzB,CAAC"}
1
+ {"version":3,"file":"generateProject.d.ts","sourceRoot":"","sources":["../../../../src/commands/generate/generateProject.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAO,MAAM,eAAe,SACpB,MAAM,OACP,MAAM,WACF,eAAe,kBAsGzB,CAAC"}
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateProject = void 0;
4
4
  const filesystem_1 = require("../../scripts/filesystem");
5
+ const git_1 = require("../../scripts/git");
5
6
  const log_1 = require("./log");
6
7
  const cmd_1 = require("../../scripts/cmd");
7
8
  const utils_1 = require("../../utils");
8
9
  const generateProject = async (name, cwd, options) => {
9
- const { noRepo, keepHistory, yes } = options;
10
+ const { starterBranch = "base", noRepo, keepHistory, yes } = options;
10
11
  log_1.log.verbose("Check if project name is valid");
11
12
  if (!name.match(/^[a-z0-9-]+$/)) {
12
13
  log_1.log.error("Project name must be lowercase, alphanumeric, and contain hyphens only.");
@@ -40,9 +41,9 @@ const generateProject = async (name, cwd, options) => {
40
41
  log_1.log.verbose("Skipping gh verification");
41
42
  }
42
43
  log_1.log.verbose("Cloning gluhar project template");
43
- (0, cmd_1.executeCmd)(`git clone --branch hui https://github.com/gluharry/starters.git ${name}`); // TODO create a git.clone; TODO allow other branches; TODO change hui to gluhar
44
+ git_1.git.clone("gluharry/starters", name, { branch: starterBranch });
44
45
  cmd_1.cmd.cd(name);
45
- log_1.log.verbose("Replacing hui-app with project's name");
46
+ log_1.log.verbose("Replacing gluhar-app with project's name");
46
47
  await filesystem_1.filesystem.copyFiles([
47
48
  "./package.json",
48
49
  "./README.md",
@@ -50,7 +51,7 @@ const generateProject = async (name, cwd, options) => {
50
51
  "./sanity/sanity.config.ts",
51
52
  "./sanity/structure.ts",
52
53
  ], (file) => {
53
- const content = file.content.replaceAll("hui-app", name);
54
+ const content = file.content.replaceAll("gluhar-app", name);
54
55
  return {
55
56
  ...file,
56
57
  content,
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,13 +36,26 @@ 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);
45
56
  // loadConfig(rootCmd, actionCmd);
57
+ // Check for newer cli version
58
+ await checkCliVersion();
46
59
  const { cwd: newCwd } = getOptions(rootCmd);
47
60
  if (newCwd && newCwd !== initCwd)
48
61
  cmd_1.cmd.cd(newCwd);
@@ -1,5 +1,5 @@
1
1
  export type ArgValue = string | number | boolean;
2
- export type Args = Record<string, ArgValue | undefined>;
2
+ export type Args = Record<string, ArgValue | undefined> | {};
3
3
  export interface ParsedArg {
4
4
  name: string;
5
5
  parsedName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface CloneOptions {
2
+ branch?: string;
3
+ singleBranch?: boolean;
4
+ }
5
+ /**
6
+ * Clone a repo.
7
+ * @param repo The repo name in the format: 'gluharry/starters'.
8
+ */
9
+ export declare const clone: (repo: string, dir?: string, options?: CloneOptions) => void;
10
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../../src/scripts/git/clone.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,SACV,MAAM,QACP,MAAM,YACF,YAAY,SAItB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clone = void 0;
4
+ const cmd_1 = require("../../scripts/cmd");
5
+ const log_1 = require("./log");
6
+ /**
7
+ * Clone a repo.
8
+ * @param repo The repo name in the format: 'gluharry/starters'.
9
+ */
10
+ const clone = (repo, dir = "", options = {}) => {
11
+ log_1.log.verbose("Cloning:", repo, dir, options);
12
+ (0, cmd_1.executeCmd)(`git clone https://github.com/${repo}.git ${dir}`, options);
13
+ };
14
+ exports.clone = clone;
@@ -23,6 +23,7 @@ export declare const git: {
23
23
  rename: (oldTagName: string, newTagName: string) => void;
24
24
  pushAll: (remote?: string) => import("child_process").SpawnSyncReturns<Buffer>;
25
25
  };
26
+ clone: (repo: string, dir?: string, options?: import("./clone").CloneOptions) => void;
26
27
  };
27
28
  export type { BranchInfo } from "./branch/getCurrentBranch";
28
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scripts/git/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAOzC,eAAO,MAAM,GAAG;;;;mBAIC,IAAI;wBACC,MAAM;uBAEP,MAAM;wBAEL,MAAM,MAAM,OAAO;;;;;;;;;;;;;;;;;CAexC,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scripts/git/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQzC,eAAO,MAAM,GAAG;;;;mBAIC,IAAI;wBACC,MAAM;uBAEP,MAAM;wBAEL,MAAM,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAgBxC,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
@@ -14,6 +14,7 @@ const getTags_1 = require("./tag/getTags");
14
14
  const pushAllTags_1 = require("./tag/pushAllTags");
15
15
  const deleteTag_1 = require("./tag/deleteTag");
16
16
  const renameTag_1 = require("./tag/renameTag");
17
+ const clone_1 = require("./clone");
17
18
  exports.git = {
18
19
  openPr: openPr_1.openPr,
19
20
  getRepo: getRepo_1.getRepo,
@@ -35,4 +36,5 @@ exports.git = {
35
36
  rename: renameTag_1.renameTag,
36
37
  pushAll: pushAllTags_1.pushAllTags,
37
38
  },
39
+ clone: clone_1.clone,
38
40
  };
@@ -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
  ]);