@gluhar/cli 2.3.2 → 2.5.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.3.2",
3
+ "version": "2.5.1",
4
4
  "description": "Gluhar cli commands and scripts",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -26,7 +26,8 @@
26
26
  "inquirer": "^8.2.6",
27
27
  "istextorbinary": "^9.5.0",
28
28
  "npmlog": "^7.0.1",
29
- "shelljs": "^0.8.5"
29
+ "shelljs": "^0.8.5",
30
+ "ts-morph": "^25.0.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@nuxt/eslint-config": "^0.5.6",
@@ -43,5 +44,5 @@
43
44
  "tsconfig-paths": "^4.2.0",
44
45
  "typescript": "^5.5.4"
45
46
  },
46
- "gitHead": "1ade1c2c6ebb8dffa3261352ab6258aea045fe38"
47
+ "gitHead": "6aeb0ebe6cec454e140af6adacd4c77bb7d5913d"
47
48
  }
@@ -1,4 +1,7 @@
1
1
  export interface DeployOptions {
2
2
  from?: string;
3
+ ios?: boolean;
4
+ android?: boolean;
5
+ ssr?: boolean;
3
6
  }
4
7
  //# sourceMappingURL=DeployOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeployOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/DeployOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"DeployOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/DeployOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
@@ -1,3 +1,3 @@
1
1
  import { DeployOptions } from "./DeployOptions";
2
- export declare const deploy: (options: DeployOptions) => void;
2
+ export declare const deploy: (options: DeployOptions) => Promise<void>;
3
3
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,eAAO,MAAM,MAAM,YAAa,aAAa,SAwB5C,CAAC"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,eAAO,MAAM,MAAM,YAAmB,aAAa,kBA+BlD,CAAC"}
@@ -3,15 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deploy = void 0;
4
4
  const git_1 = require("../../scripts/git");
5
5
  const log_1 = require("./log");
6
- const deploy = (options) => {
7
- log_1.log.info("Deploying app...");
8
- const fromBranch = options.from || "dev";
9
- const { local, remote } = git_1.git.branch.exists("deploy");
10
- if (!local || !remote) {
11
- log_1.log.error("Branch 'deploy' does not exists or has not been pushed to or pulled from remote yet.");
6
+ const deployIos_1 = require("./deployIos");
7
+ const setSsr_1 = require("./setSsr");
8
+ const deploy = async (options) => {
9
+ log_1.log.info("Deploying app...", options);
10
+ // Deploy app to iOS
11
+ if (options.ios) {
12
+ (0, deployIos_1.deployIos)(options);
12
13
  return;
13
14
  }
14
- git_1.git.branch.checkout("deploy");
15
+ // Handle ssr
16
+ if (options.ssr !== undefined) {
17
+ log_1.log.info(`Setting ssr to ${options.ssr} and committing to git`);
18
+ (0, setSsr_1.setSsr)(options.ssr);
19
+ git_1.git.commit("chore: Set SSR to " + options.ssr);
20
+ }
21
+ // Default Deploy app to web
22
+ const fromBranch = options.from || "dev";
23
+ const { remote } = git_1.git.branch.exists("deploy");
24
+ git_1.git.branch.checkout("deploy", { newBranch: !remote });
15
25
  log_1.log.info("Checked out to deploy branch");
16
26
  git_1.git.merge(fromBranch, true);
17
27
  log_1.log.info(`Merged with ${fromBranch}`);
@@ -0,0 +1,3 @@
1
+ import { DeployOptions } from "./DeployOptions";
2
+ export declare const deployIos: (options: DeployOptions) => Promise<void>;
3
+ //# sourceMappingURL=deployIos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployIos.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/deployIos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAUhD,eAAO,MAAM,SAAS,YAAmB,aAAa,kBA2BrD,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deployIos = void 0;
4
+ const cmd_1 = require("../../scripts/cmd");
5
+ const log_1 = require("./log");
6
+ const ts_morph_1 = require("ts-morph");
7
+ const setSsr_1 = require("./setSsr");
8
+ const project = new ts_morph_1.Project();
9
+ const deployIos = async (options) => {
10
+ log_1.log.info("Deploying iOS app.");
11
+ // Remove server dev url from capacitor config
12
+ const capConfig = project.addSourceFileAtPathIfExists("./capacitor.config.ts");
13
+ if (!capConfig)
14
+ return;
15
+ const capConfigObject = capConfig
16
+ ?.getVariableDeclaration("config")
17
+ ?.getInitializerIfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
18
+ if (!capConfigObject)
19
+ return;
20
+ capConfigObject.getProperty("server")?.remove();
21
+ capConfig.saveSync();
22
+ // Disable ssr from nuxt.config
23
+ (0, setSsr_1.setSsr)(false);
24
+ // Generate static nuxt app
25
+ (0, cmd_1.executeCmd)("nuxi generate");
26
+ // Sync and open iOS app with Capacitor
27
+ (0, cmd_1.executeCmd)("cap sync ios");
28
+ (0, cmd_1.executeCmd)("cap open ios");
29
+ };
30
+ exports.deployIos = deployIos;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAGpC,wBAUkB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;;AAGpC,wBAgBkB"}
@@ -6,4 +6,7 @@ exports.default = new commander_1.Command()
6
6
  .name("deploy")
7
7
  .description("Deploy a Nuxt app. Check out to deploy branch, merge with dev and check out back to dev.")
8
8
  .option("--from", "From what branch to deploy. Default is 'dev' so this is used in the event we are deploying from a different branch.", "dev")
9
+ .option("--ios", "Deploy app to iOS device using Capacitor.")
10
+ .option("--android", "Deploy app to Android device using Capacitor.")
11
+ .option("--ssr", "Set SSR before deployment. Default is undefined for no change.")
9
12
  .action(deploy_1.deploy);
@@ -0,0 +1,2 @@
1
+ export declare const setSsr: (ssr: boolean) => void;
2
+ //# sourceMappingURL=setSsr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setSsr.d.ts","sourceRoot":"","sources":["../../../../src/commands/deploy/setSsr.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,QAAS,OAAO,SAoBlC,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSsr = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ const project = new ts_morph_1.Project();
6
+ const setSsr = (ssr) => {
7
+ const nuxtConfig = project.addSourceFileAtPath("./nuxt.config.ts");
8
+ if (!nuxtConfig)
9
+ return;
10
+ const nuxtConfigDefault = nuxtConfig?.getFirstDescendantByKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
11
+ if (!nuxtConfigDefault)
12
+ return;
13
+ const nuxtConfigSsr = nuxtConfigDefault.getProperty("ssr");
14
+ if (nuxtConfigSsr) {
15
+ nuxtConfigSsr.set({ initializer: `${ssr}` });
16
+ }
17
+ else {
18
+ nuxtConfigDefault.addPropertyAssignment({
19
+ name: "ssr",
20
+ initializer: `${ssr}`,
21
+ });
22
+ }
23
+ nuxtConfig.saveSync();
24
+ };
25
+ exports.setSsr = setSsr;
@@ -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;AAmEzC,eAAO,MAAM,SAAS,YAAmB,OAAO,aAAa,OAAO,kBAoBnE,CAAC"}
1
+ {"version":3,"file":"preAction.d.ts","sourceRoot":"","sources":["../../src/preAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsEzC,eAAO,MAAM,SAAS,YAAmB,OAAO,aAAa,OAAO,kBAoBnE,CAAC"}
package/src/preAction.js CHANGED
@@ -5,6 +5,7 @@ const utils_1 = require("./utils");
5
5
  // import { getConfigOpt, setConfigOpt } from './config';
6
6
  const cmd_1 = require("./scripts/cmd");
7
7
  const constants_1 = require("./constants");
8
+ const git_1 = require("./scripts/git");
8
9
  const getOptions = (command) => command.opts();
9
10
  const log = (0, utils_1.logger)("cli");
10
11
  // const loadConfig = (rootCmd: Command, actionCmd: Command) => {
@@ -37,6 +38,8 @@ const logCli = (actionCmd) => {
37
38
  log.verbose("cwd:", process.cwd());
38
39
  };
39
40
  const checkCliVersion = async () => {
41
+ if (git_1.git.getRepo() === "gluhar")
42
+ return;
40
43
  const latestVersion = (0, cmd_1.getCmdOutput)("npm show @gluhar/cli version");
41
44
  // Version is up to date
42
45
  if (latestVersion === constants_1.VERSION)