@gluhar/cli 3.1.5 → 6.0.0-next.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.
Files changed (56) hide show
  1. package/package.json +11 -4
  2. package/src/commands/danka/DankaOptions.d.ts +4 -0
  3. package/src/commands/danka/DankaOptions.d.ts.map +1 -0
  4. package/src/commands/danka/DankaOptions.js +2 -0
  5. package/src/commands/danka/danka.d.ts +3 -0
  6. package/src/commands/danka/danka.d.ts.map +1 -0
  7. package/src/commands/danka/danka.js +8 -0
  8. package/src/commands/danka/index.d.ts +4 -0
  9. package/src/commands/danka/index.d.ts.map +1 -0
  10. package/src/commands/danka/index.js +9 -0
  11. package/src/commands/danka/log.d.ts +2 -0
  12. package/src/commands/danka/log.d.ts.map +1 -0
  13. package/src/commands/danka/log.js +5 -0
  14. package/src/commands/generate/generateProject.d.ts.map +1 -1
  15. package/src/commands/generate/generateProject.js +3 -2
  16. package/src/commands/kiss/KissOptions.d.ts +4 -0
  17. package/src/commands/kiss/KissOptions.d.ts.map +1 -0
  18. package/src/commands/kiss/KissOptions.js +2 -0
  19. package/src/commands/kiss/index.d.ts +4 -0
  20. package/src/commands/kiss/index.d.ts.map +1 -0
  21. package/src/commands/kiss/index.js +9 -0
  22. package/src/commands/kiss/kiss.d.ts +3 -0
  23. package/src/commands/kiss/kiss.d.ts.map +1 -0
  24. package/src/commands/kiss/kiss.js +8 -0
  25. package/src/commands/kiss/log.d.ts +2 -0
  26. package/src/commands/kiss/log.d.ts.map +1 -0
  27. package/src/commands/kiss/log.js +5 -0
  28. package/src/commands/release/ReleaseOptions.d.ts +1 -0
  29. package/src/commands/release/ReleaseOptions.d.ts.map +1 -1
  30. package/src/commands/release/index.d.ts.map +1 -1
  31. package/src/commands/release/index.js +6 -2
  32. package/src/commands/release/publish.d.ts.map +1 -1
  33. package/src/commands/release/publish.js +3 -1
  34. package/src/commands/release/release.d.ts.map +1 -1
  35. package/src/commands/release/release.js +8 -1
  36. package/src/commands/release/tag.d.ts.map +1 -1
  37. package/src/commands/release/tag.js +5 -2
  38. package/src/commands/upgrade/UpgradeOptions.d.ts +2 -1
  39. package/src/commands/upgrade/UpgradeOptions.d.ts.map +1 -1
  40. package/src/commands/upgrade/index.js +2 -2
  41. package/src/commands/upgrade/upgrade.d.ts.map +1 -1
  42. package/src/commands/upgrade/upgrade.js +14 -3
  43. package/src/commands/version/version.d.ts.map +1 -1
  44. package/src/commands/version/version.js +3 -1
  45. package/src/preAction.d.ts.map +1 -1
  46. package/src/preAction.js +7 -6
  47. package/src/scripts/cmd/exitOnFailure.d.ts +8 -0
  48. package/src/scripts/cmd/exitOnFailure.d.ts.map +1 -0
  49. package/src/scripts/cmd/exitOnFailure.js +20 -0
  50. package/src/scripts/cmd/index.d.ts +1 -0
  51. package/src/scripts/cmd/index.d.ts.map +1 -1
  52. package/src/scripts/cmd/index.js +1 -0
  53. package/src/scripts/git/index.d.ts +1 -1
  54. package/src/scripts/git/tag/createTag.d.ts +1 -1
  55. package/src/scripts/git/tag/createTag.d.ts.map +1 -1
  56. package/src/scripts/git/tag/createTag.js +1 -1
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@gluhar/cli",
3
- "version": "3.1.5",
3
+ "version": "6.0.0-next.0",
4
4
  "description": "Gluhar cli commands and scripts",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/gluharco/gluhar.git",
8
+ "directory": "packages/cli"
9
+ },
5
10
  "exports": {
6
11
  ".": "./src/index.ts",
7
12
  "./*": "./src/*/index.ts"
8
13
  },
9
14
  "main": "./src/index.js",
10
15
  "bin": {
11
- "gluhar": "./src/index.js"
16
+ "gluhar": "src/index.js"
12
17
  },
13
18
  "scripts": {
14
19
  "clean": "rm -rf dist",
@@ -26,6 +31,7 @@
26
31
  "inquirer": "^8.2.6",
27
32
  "istextorbinary": "^9.5.0",
28
33
  "npmlog": "^7.0.1",
34
+ "semver": "^7.8.5",
29
35
  "shelljs": "^0.8.5",
30
36
  "ts-morph": "^25.0.0"
31
37
  },
@@ -36,13 +42,14 @@
36
42
  "@types/humps": "^2.0.6",
37
43
  "@types/inquirer": "^8.2.10",
38
44
  "@types/istextorbinary": "^2.3.4",
39
- "@types/node": "^20.16.5",
45
+ "@types/node": "^22.5.4",
40
46
  "@types/npmlog": "^7.0.0",
47
+ "@types/semver": "^7.8.0",
41
48
  "@types/shelljs": "^0.8.15",
42
49
  "eslint": "^9.10.0",
43
50
  "tsc-alias": "^1.8.10",
44
51
  "tsconfig-paths": "^4.2.0",
45
52
  "typescript": "^5.5.4"
46
53
  },
47
- "gitHead": "a60bf29f338bc3af3212a3a8ed647f75c69a2c4a"
54
+ "gitHead": "8773cd99c43cbe6a7dc415e50af8b13a7b8d4daf"
48
55
  }
@@ -0,0 +1,4 @@
1
+ export interface DankaOptions {
2
+ danka: boolean;
3
+ }
4
+ //# sourceMappingURL=DankaOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DankaOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/danka/DankaOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { DankaOptions } from "./DankaOptions";
2
+ export declare const danka: (options: DankaOptions) => void;
3
+ //# sourceMappingURL=danka.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"danka.d.ts","sourceRoot":"","sources":["../../../../src/commands/danka/danka.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,KAAK,YAAa,YAAY,SAE1C,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.danka = void 0;
4
+ const log_1 = require("./log");
5
+ const danka = (options) => {
6
+ log_1.log.info("danka", options);
7
+ };
8
+ exports.danka = danka;
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ declare const _default: Command;
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/danka/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAGpC,wBAIiB"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const danka_1 = require("./danka");
5
+ exports.default = new commander_1.Command()
6
+ .name("danka")
7
+ .description("Description of command.")
8
+ .option("-b, --danka", "A boolean option.")
9
+ .action(danka_1.danka);
@@ -0,0 +1,2 @@
1
+ export declare const log: import("../../utils").Logger;
2
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/commands/danka/log.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,4BAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = void 0;
4
+ const utils_1 = require("../../utils");
5
+ exports.log = (0, utils_1.logger)("danka");
@@ -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,GAC1B,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,SAAS,eAAe,kBAuGzB,CAAC"}
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,GAC1B,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,SAAS,eAAe,kBAwGzB,CAAC"}
@@ -8,7 +8,8 @@ const common_1 = require("../../utils/common");
8
8
  const cmd_1 = require("../../scripts/cmd");
9
9
  const utils_1 = require("../../utils");
10
10
  const generateProject = async (name, cwd, options) => {
11
- const { starter = "base", noRepo, keepHistory, yes } = options;
11
+ // `dev` is the starters' main branch; others (e.g. `mobile`) are variants.
12
+ const { starter = "dev", noRepo, keepHistory, yes } = options;
12
13
  log_1.log.verbose("Check if project name is valid");
13
14
  if (!name.match(/^[a-z0-9-]+$/)) {
14
15
  log_1.log.error("Project name must be lowercase, alphanumeric, and contain hyphens only.");
@@ -42,7 +43,7 @@ const generateProject = async (name, cwd, options) => {
42
43
  log_1.log.verbose("Skipping gh verification");
43
44
  }
44
45
  log_1.log.verbose("Cloning gluhar project template");
45
- git_1.git.clone("gluharry/starters", name, { branch: starter });
46
+ git_1.git.clone("gluharco/starters", name, { branch: starter });
46
47
  cmd_1.cmd.cd(name);
47
48
  log_1.log.verbose("Replacing gluhar-app with project's name");
48
49
  await filesystem_1.filesystem.copyFiles([
@@ -0,0 +1,4 @@
1
+ export interface KissOptions {
2
+ kiss: boolean;
3
+ }
4
+ //# sourceMappingURL=KissOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KissOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/kiss/KissOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { Command } from "commander";
2
+ declare const _default: Command;
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/kiss/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAGpC,wBAIgB"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const kiss_1 = require("./kiss");
5
+ exports.default = new commander_1.Command()
6
+ .name("kiss")
7
+ .description("Description of command.")
8
+ .option("-b, --kiss", "A boolean option.")
9
+ .action(kiss_1.kiss);
@@ -0,0 +1,3 @@
1
+ import { KissOptions } from "./KissOptions";
2
+ export declare const kiss: (options: KissOptions) => void;
3
+ //# sourceMappingURL=kiss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiss.d.ts","sourceRoot":"","sources":["../../../../src/commands/kiss/kiss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,eAAO,MAAM,IAAI,YAAa,WAAW,SAExC,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kiss = void 0;
4
+ const log_1 = require("./log");
5
+ const kiss = (options) => {
6
+ log_1.log.info("kiss", options);
7
+ };
8
+ exports.kiss = kiss;
@@ -0,0 +1,2 @@
1
+ export declare const log: import("../../utils").Logger;
2
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/commands/kiss/log.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,4BAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = void 0;
4
+ const utils_1 = require("../../utils");
5
+ exports.log = (0, utils_1.logger)("kiss");
@@ -4,6 +4,7 @@ export interface ReleaseOptions {
4
4
  directory: string;
5
5
  yes: boolean;
6
6
  version: boolean;
7
+ publish: boolean;
7
8
  gitTag: boolean | string;
8
9
  }
9
10
  //# sourceMappingURL=ReleaseOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReleaseOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/ReleaseOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B"}
1
+ {"version":3,"file":"ReleaseOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/ReleaseOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAIpC,wBAmCmB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAIpC,wBA6CmB"}
@@ -5,11 +5,15 @@ const release_1 = require("./release");
5
5
  const tag_1 = require("./tag");
6
6
  exports.default = new commander_1.Command()
7
7
  .name("release")
8
- .description("Release and publish packages to the npm registry.")
8
+ .description([
9
+ "Version packages, then tag and push. The `v*` tag triggers .github/workflows/release.yml,",
10
+ "which publishes to npm through trusted publishing (no OTP).",
11
+ ].join("\n"))
9
12
  .option("-y, --yes", "When run with this flag, we will skip all confirmation prompts. NOTE does not currently work.", false)
10
13
  .option("--pre [id]", "Prerelease identifier. Use this when releasing a prerelease version.", false)
11
14
  .option("-d, --dev", "Release a dev version. This is a shorthand for a prerelease with a 'dev' identifier.", false)
12
- .option("--dir, --directory <path>", "Subdirectory to publish. Must apply to ALL packages, and MUST contain a package.json file.", "dist")
15
+ .option("--publish", "Also publish from this machine with lerna (asks for an npm OTP). Only needed for packages that aren't on npm yet, since trusted publishing can't be set up before a first publish.", false)
16
+ .option("--dir, --directory <path>", "Subdirectory to publish with --publish. Must apply to ALL packages, and MUST contain a package.json file.", "dist")
13
17
  .option("--no-version", "Disable versioning and changelog gen.")
14
18
  .option("--git-tag [tag]", [
15
19
  "Create and push git tag(s). Optionally provide a template.",
@@ -1 +1 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/publish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,eAAO,MAAM,OAAO,GAAI,SAAS,cAAc,SAY9C,CAAC"}
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,eAAO,MAAM,OAAO,GAAI,SAAS,cAAc,SAa9C,CAAC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.publish = void 0;
4
4
  const lerna_1 = require("../../scripts/lerna");
5
+ const cmd_1 = require("../../scripts/cmd");
5
6
  const log_1 = require("./log");
6
7
  const getPreid_1 = require("../version/getPreid");
7
8
  const publish = (options) => {
@@ -9,10 +10,11 @@ const publish = (options) => {
9
10
  const distTag = dev ? "dev" : (0, getPreid_1.getPreid)(pre) ?? "latest";
10
11
  log_1.log.info("Dist tag:", distTag);
11
12
  log_1.log.info("Directory:", directory);
12
- lerna_1.lerna.publish({
13
+ const result = lerna_1.lerna.publish({
13
14
  distTag,
14
15
  contents: directory,
15
16
  yes,
16
17
  });
18
+ (0, cmd_1.exitOnFailure)(result, "lerna publish");
17
19
  };
18
20
  exports.publish = publish;
@@ -1 +1 @@
1
- {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/release.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,kBAiBpD,CAAC"}
1
+ {"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/release.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,kBAwBpD,CAAC"}
@@ -18,7 +18,14 @@ const release = async (options) => {
18
18
  changelog: !dev,
19
19
  commit: "chore: Releasing gluhar packages.",
20
20
  });
21
- (0, publish_1.publish)(options);
21
+ if (options.publish)
22
+ (0, publish_1.publish)(options);
22
23
  await (0, tag_1.tag)(options);
24
+ if (!options.publish) {
25
+ if (options.gitTag)
26
+ log_1.log.info("Pushed the tag; GitHub Actions publishes to npm (workflow: Release).");
27
+ else
28
+ log_1.log.warn("Nothing was published: pass --git-tag for CI, or --publish to publish locally.");
29
+ }
23
30
  };
24
31
  exports.release = release;
@@ -1 +1 @@
1
- {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/tag.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,OAAO;IAClB,yBAAyB;;IAEzB,iBAAiB;;IAEjB,mBAAmB;;;QAGjB,wBAAwB;;QAExB,oBAAoB;;;CAGvB,CAAC;AAiBF,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,EAAE,KAAK,WAAW,KAAG,MAyBnE,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,SAAS,cAAc,kBAgDhD,CAAC"}
1
+ {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/commands/release/tag.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,eAAO,MAAM,OAAO;IAClB,yBAAyB;;IAEzB,iBAAiB;;IAEjB,mBAAmB;;;QAGjB,wBAAwB;;QAExB,oBAAoB;;;CAGvB,CAAC;AAiBF,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,YAAY,MAAM,EAAE,KAAK,WAAW,KAAG,MAyBnE,CAAC;AAEF,eAAO,MAAM,GAAG,GAAU,SAAS,cAAc,kBAkDhD,CAAC"}
@@ -5,6 +5,7 @@ const lerna_1 = require("../../scripts/lerna");
5
5
  const constants_1 = require("../../scripts/lerna/constants");
6
6
  const git_1 = require("../../scripts/git");
7
7
  const utils_1 = require("../../utils");
8
+ const cmd_1 = require("../../scripts/cmd");
8
9
  const log_1 = require("./log");
9
10
  exports.pattern = {
10
11
  /** e.g. `@gluhar/cli` */
@@ -82,9 +83,11 @@ const tag = async (options) => {
82
83
  const confirm = await (0, utils_1.confirmQuestion)(`Create and push tag(s): ${tagList}. Confirm?`, yes);
83
84
  if (confirm) {
84
85
  tags.forEach((t) => {
85
- git_1.git.tag.create(t);
86
+ (0, cmd_1.exitOnFailure)(git_1.git.tag.create(t), `git tag ${t}`);
86
87
  });
87
- git_1.git.tag.pushAll();
88
+ // The branch first, so the release commit is on it before CI starts from the tag
89
+ (0, cmd_1.exitOnFailure)(git_1.git.push("HEAD"), "git push");
90
+ (0, cmd_1.exitOnFailure)(git_1.git.tag.pushAll(), "git push --tags");
88
91
  }
89
92
  };
90
93
  exports.tag = tag;
@@ -1,4 +1,5 @@
1
1
  export interface UpgradeOptions {
2
- upgrade: boolean;
2
+ /** npm dist-tag or version to install, e.g. `latest`, `next`, `6`. */
3
+ tag: string;
3
4
  }
4
5
  //# sourceMappingURL=UpgradeOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UpgradeOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/upgrade/UpgradeOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"UpgradeOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/upgrade/UpgradeOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;CACb"}
@@ -4,6 +4,6 @@ const commander_1 = require("commander");
4
4
  const upgrade_1 = require("./upgrade");
5
5
  exports.default = new commander_1.Command()
6
6
  .name("upgrade")
7
- .description("Upgrade all gluhar dependencies in a project to their latest versions.")
8
- .option("-b, --upgrade", "A boolean option.")
7
+ .description("Upgrade all @gluhar/* dependencies in a project, across major versions.")
8
+ .option("-t, --tag <tag>", "npm dist-tag or version to install.", "latest")
9
9
  .action(upgrade_1.upgrade);
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../../src/commands/upgrade/upgrade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,eAAO,MAAM,OAAO,GAAI,SAAS,cAAc,SAK9C,CAAC"}
1
+ {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../../src/commands/upgrade/upgrade.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,eAAO,MAAM,OAAO,GAAI,SAAS,cAAc,SAiB9C,CAAC"}
@@ -1,11 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.upgrade = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
4
6
  const cmd_1 = require("../../scripts/cmd");
5
7
  const log_1 = require("./log");
6
8
  const upgrade = (options) => {
7
- log_1.log.info("Upgrading gluhar dependencies.");
8
- // Upgrade all gluhar dependencies in a project to their latest versions.
9
- (0, cmd_1.executeCmd)("npm update @gluhar/cli @gluhar/app");
9
+ const { tag } = options;
10
+ log_1.log.info(`Upgrading gluhar dependencies to "${tag}".`);
11
+ const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), "package.json")).toString());
12
+ const names = Object.keys({
13
+ ...pkg.dependencies,
14
+ ...pkg.devDependencies,
15
+ }).filter((name) => name.startsWith("@gluhar/"));
16
+ if (!names.length)
17
+ return log_1.log.info("No @gluhar/* dependencies found.");
18
+ // `npm install pkg@tag`, not `npm update`: update stays inside the semver
19
+ // range already in package.json, so it can never cross a major version.
20
+ (0, cmd_1.executeCmd)(`npm install ${names.map((name) => `${name}@${tag}`).join(" ")}`);
10
21
  };
11
22
  exports.upgrade = upgrade;
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/commands/version/version.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,kBAyBpD,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/commands/version/version.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,eAAO,MAAM,OAAO,GAAU,SAAS,cAAc,kBA0BpD,CAAC"}
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  const lerna_1 = require("../../scripts/lerna");
5
5
  const git_1 = require("../../scripts/git");
6
+ const cmd_1 = require("../../scripts/cmd");
6
7
  const log_1 = require("./log");
7
8
  const getPreid_1 = require("./getPreid");
8
9
  const pimpChangelogs_1 = require("./pimpChangelogs");
9
10
  const version = async (options) => {
10
11
  const { pre, dev, changelog, commit, yes } = options;
11
- lerna_1.lerna.version({
12
+ const result = lerna_1.lerna.version({
12
13
  conventionalCommits: true,
13
14
  conventionalGraduate: (!dev && !pre) || undefined,
14
15
  conventionalPrerelease: !!dev || !!pre || undefined,
@@ -20,6 +21,7 @@ const version = async (options) => {
20
21
  changelog,
21
22
  yes,
22
23
  });
24
+ (0, cmd_1.exitOnFailure)(result, "lerna version");
23
25
  if (changelog)
24
26
  await (0, pimpChangelogs_1.pimpChangelogs)();
25
27
  if (commit) {
@@ -1 +1 @@
1
- {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6EzC,eAAO,MAAM,SAAS,GAAU,SAAS,OAAO,EAAE,WAAW,OAAO,kBAoBnE,CAAC"}
1
+ {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8EzC,eAAO,MAAM,SAAS,GAAU,SAAS,OAAO,EAAE,WAAW,OAAO,kBAoBnE,CAAC"}
package/src/preAction.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preAction = void 0;
4
- const fs_1 = require("fs");
4
+ const path_1 = require("path");
5
+ const semver_1 = require("semver");
5
6
  const utils_1 = require("./utils");
6
7
  const cmd_1 = require("./scripts/cmd");
7
8
  const constants_1 = require("./constants");
8
- const git_1 = require("./scripts/git");
9
9
  // import { getConfigOpt, setConfigOpt } from './config';
10
10
  const getOptions = (command) => command.opts();
11
11
  const log = (0, utils_1.logger)("cli");
@@ -38,16 +38,17 @@ const logCli = (actionCmd) => {
38
38
  log.verbose("options:", getOptions(actionCmd));
39
39
  log.verbose("cwd:", process.cwd());
40
40
  };
41
+ /** The CLI runs from the monorepo checkout (`packages/cli/dist`), not from an install. */
42
+ const isDevCheckout = () => !__dirname.split(path_1.sep).includes("node_modules");
41
43
  const checkCliVersion = async (rootCmd) => {
42
- const hasGit = (0, fs_1.existsSync)(".git");
43
- if (hasGit && git_1.git.getRepo() === "gluhar")
44
+ if (isDevCheckout())
44
45
  return;
45
46
  // Skip version check entirely when not in an interactive terminal
46
47
  if (!process.stdout.isTTY)
47
48
  return;
48
49
  const latestVersion = (0, cmd_1.getCmdOutput)("npm show @gluhar/cli version");
49
- // Version is up to date
50
- if (latestVersion === constants_1.VERSION)
50
+ // Only offer an upgrade, never a downgrade from a prerelease to `latest`
51
+ if (!(0, semver_1.valid)(latestVersion) || !(0, semver_1.gt)(latestVersion, constants_1.VERSION))
51
52
  return;
52
53
  const { yes } = getOptions(rootCmd);
53
54
  // Version is old, ask to install latest
@@ -0,0 +1,8 @@
1
+ import type { SpawnSyncReturns } from 'child_process';
2
+ /**
3
+ * Exits the process when a spawned command failed, so later steps don't run on a broken state.
4
+ * @param result The return value of `executeBash` / `executeCmd`.
5
+ * @param label What failed, for the error message: 'lerna publish'.
6
+ */
7
+ export declare const exitOnFailure: (result: SpawnSyncReturns<Buffer>, label: string) => void;
8
+ //# sourceMappingURL=exitOnFailure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exitOnFailure.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/exitOnFailure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,MAAM,SAWd,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exitOnFailure = void 0;
4
+ const log_1 = require("./log");
5
+ /**
6
+ * Exits the process when a spawned command failed, so later steps don't run on a broken state.
7
+ * @param result The return value of `executeBash` / `executeCmd`.
8
+ * @param label What failed, for the error message: 'lerna publish'.
9
+ */
10
+ const exitOnFailure = (result, label) => {
11
+ if (result.error) {
12
+ log_1.log.error(`${label} could not run:`, result.error.message);
13
+ process.exit(1);
14
+ }
15
+ if (result.status !== 0) {
16
+ log_1.log.error(`${label} failed with exit code ${result.status ?? result.signal}.`);
17
+ process.exit(result.status || 1);
18
+ }
19
+ };
20
+ exports.exitOnFailure = exitOnFailure;
@@ -2,6 +2,7 @@ export * from './executeBash';
2
2
  export * from './executeCmd';
3
3
  export * from './getCmdOutput';
4
4
  export * from './getBashOutput';
5
+ export * from './exitOnFailure';
5
6
  export declare const cmd: {
6
7
  cd: (path: string) => void;
7
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,eAAO,MAAM,GAAG;;CAEf,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scripts/cmd/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAEhC,eAAO,MAAM,GAAG;;CAEf,CAAC"}
@@ -20,6 +20,7 @@ __exportStar(require("./executeBash"), exports);
20
20
  __exportStar(require("./executeCmd"), exports);
21
21
  __exportStar(require("./getCmdOutput"), exports);
22
22
  __exportStar(require("./getBashOutput"), exports);
23
+ __exportStar(require("./exitOnFailure"), exports);
23
24
  exports.cmd = {
24
25
  cd: cd_1.cd,
25
26
  };
@@ -18,7 +18,7 @@ export declare const git: {
18
18
  };
19
19
  tag: {
20
20
  getAll: () => string[];
21
- create: (name: string, options?: import("./tag/createTag").TagCreateOptions) => void;
21
+ create: (name: string, options?: import("./tag/createTag").TagCreateOptions) => import("child_process").SpawnSyncReturns<Buffer>;
22
22
  delete: (name: string) => void;
23
23
  rename: (oldTagName: string, newTagName: string) => void;
24
24
  pushAll: (remote?: string) => import("child_process").SpawnSyncReturns<Buffer>;
@@ -14,5 +14,5 @@ export interface TagCreateOptions {
14
14
  * @param name The name of the tag to create.
15
15
  * @param object The object that the new tag will refer to, usually a commit. Defaults to HEAD.
16
16
  */
17
- export declare const createTag: (name: string, options?: TagCreateOptions) => void;
17
+ export declare const createTag: (name: string, options?: TagCreateOptions) => import("child_process").SpawnSyncReturns<Buffer>;
18
18
  //# sourceMappingURL=createTag.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createTag.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/git/tag/createTag.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,UAAS,gBAAqB,SAOrE,CAAC"}
1
+ {"version":3,"file":"createTag.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/git/tag/createTag.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,UAAS,gBAAqB,qDAOrE,CAAC"}
@@ -9,7 +9,7 @@ const cmd_1 = require("../../cmd");
9
9
  */
10
10
  const createTag = (name, options = {}) => {
11
11
  const { object = '', force } = options;
12
- (0, cmd_1.executeCmd)(`git tag ${name} ${object}`, {
12
+ return (0, cmd_1.executeCmd)(`git tag ${name} ${object}`, {
13
13
  force,
14
14
  annotate: true,
15
15
  message: '',