@multiplatform.one/cli 1.0.31 → 1.0.33

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.
@@ -14,7 +14,9 @@ program.command("init").argument("[remote]", "the remote to use", "https://gitla
14
14
  if ((await execa("git", [
15
15
  "rev-parse",
16
16
  "--is-inside-work-tree"
17
- ])).stdout.trim() === "true") {
17
+ ], {
18
+ reject: false
19
+ })).exitCode === 0) {
18
20
  throw new Error("multiplatform.one cannot be initialized inside a git repository");
19
21
  }
20
22
  const cookieCutterConfig = {
@@ -26,7 +28,7 @@ program.command("init").argument("[remote]", "the remote to use", "https://gitla
26
28
  }
27
29
  ]))?.name
28
30
  };
29
- const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), "multiplatform-"));
31
+ const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), "multiplatform-")), "config.json");
30
32
  await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2));
31
33
  await execa("sh", [
32
34
  path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/init.sh"),
@@ -42,14 +44,18 @@ program.command("update").argument("[remote]", "the remote to use", "https://git
42
44
  if ((await execa("git", [
43
45
  "rev-parse",
44
46
  "--is-inside-work-tree"
45
- ])).stdout.trim() !== "true") {
47
+ ], {
48
+ reject: false
49
+ })).exitCode !== 0) {
46
50
  throw new Error("multiplatform.one cannot be updated outside of a git repository");
47
51
  }
48
52
  if ((await execa("git", [
49
53
  "diff",
50
54
  "--cached",
51
55
  "--quiet"
52
- ])).stdout.trim() !== "true") {
56
+ ], {
57
+ reject: false
58
+ })).exitCode !== 0) {
53
59
  throw new Error("multiplatform.one cannot be updated with uncommitted changes");
54
60
  }
55
61
  const projectRoot = (await execa("git", [
@@ -64,7 +70,7 @@ program.command("update").argument("[remote]", "the remote to use", "https://git
64
70
  };
65
71
  }
66
72
  if (!cookieCutterConfig) throw new Error("not a multiplatform.one project");
67
- const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), "multiplatform-"));
73
+ const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), "multiplatform-")), "config.json");
68
74
  await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2));
69
75
  await execa("sh", [
70
76
  path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/update.sh"),
@@ -73,8 +79,8 @@ program.command("update").argument("[remote]", "the remote to use", "https://git
73
79
  cookieCutterConfigFile,
74
80
  remote
75
81
  ], {
76
- stdio: "inherit",
77
- cwd: projectRoot
82
+ cwd: projectRoot,
83
+ stdio: "inherit"
78
84
  });
79
85
  });
80
86
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/cli",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "author": "BitSpur <support@bitspur.com> (https://bitspur.com)",
5
5
  "contributors": [
6
6
  {
@@ -52,7 +52,7 @@
52
52
  "@types/node": "~20.12.13",
53
53
  "tsup": "^8.1.0",
54
54
  "typescript": "~5.3.3",
55
- "@multiplatform.one/utils": "^0.0.16"
55
+ "@multiplatform.one/utils": "^0.0.18"
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "^9.5.0",
@@ -4,7 +4,7 @@
4
4
  * File Created: 22-06-2024 14:17:12
5
5
  * Author: Clay Risser
6
6
  * -----
7
- * BitSpur (c) Copyright 2021 - 2024
7
+ * BitSpur Copyright 2021 - 2024
8
8
  *
9
9
  * Licensed under the Apache License, Version 2.0 (the "License");
10
10
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ program
43
43
  .option('--name <name>', 'the name of the project')
44
44
  .description('init multiplatform.one')
45
45
  .action(async (remote) => {
46
- if ((await execa('git', ['rev-parse', '--is-inside-work-tree'])).stdout.trim() === 'true') {
46
+ if ((await execa('git', ['rev-parse', '--is-inside-work-tree'], { reject: false })).exitCode === 0) {
47
47
  throw new Error('multiplatform.one cannot be initialized inside a git repository');
48
48
  }
49
49
  const cookieCutterConfig: CookieCutterConfig = {
@@ -59,7 +59,7 @@ program
59
59
  ])
60
60
  )?.name,
61
61
  };
62
- const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-'));
62
+ const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-')), 'config.json');
63
63
  await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2));
64
64
  await execa(
65
65
  'sh',
@@ -81,10 +81,16 @@ program
81
81
  .argument('[remote]', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
82
82
  .description('update multiplatform.one')
83
83
  .action(async (remote) => {
84
- if ((await execa('git', ['rev-parse', '--is-inside-work-tree'])).stdout.trim() !== 'true') {
84
+ if ((await execa('git', ['rev-parse', '--is-inside-work-tree'], { reject: false })).exitCode !== 0) {
85
85
  throw new Error('multiplatform.one cannot be updated outside of a git repository');
86
86
  }
87
- if ((await execa('git', ['diff', '--cached', '--quiet'])).stdout.trim() !== 'true') {
87
+ if (
88
+ (
89
+ await execa('git', ['diff', '--cached', '--quiet'], {
90
+ reject: false,
91
+ })
92
+ ).exitCode !== 0
93
+ ) {
88
94
  throw new Error('multiplatform.one cannot be updated with uncommitted changes');
89
95
  }
90
96
  const projectRoot = (await execa('git', ['rev-parse', '--show-toplevel'])).stdout.trim();
@@ -100,7 +106,7 @@ program
100
106
  if (name) cookieCutterConfig = { name };
101
107
  }
102
108
  if (!cookieCutterConfig) throw new Error('not a multiplatform.one project');
103
- const cookieCutterConfigFile = await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-'));
109
+ const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-')), 'config.json');
104
110
  await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2));
105
111
  await execa(
106
112
  'sh',
@@ -112,8 +118,8 @@ program
112
118
  remote,
113
119
  ],
114
120
  {
115
- stdio: 'inherit',
116
121
  cwd: projectRoot,
122
+ stdio: 'inherit',
117
123
  },
118
124
  );
119
125
  });