@multiplatform.one/cli 1.0.30 → 1.0.32

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.
@@ -1,20 +1,22 @@
1
1
  // src/bin/multiplatformOne.ts
2
2
  import fs from "fs/promises";
3
+ import fsSync from "fs";
3
4
  import inquirer from "inquirer";
4
5
  import os from "os";
5
6
  import path from "path";
6
- import pkg from "@multiplatform.one/cli/package.json";
7
7
  import { execa } from "execa";
8
8
  import { fileURLToPath } from "url";
9
9
  import { program } from "commander";
10
10
  process.env.COOKIECUTTER = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/cookiecutter.sh");
11
11
  program.name("multiplatform.one");
12
- program.version(pkg.version);
12
+ program.version(JSON.parse(fsSync.readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf8"))?.version);
13
13
  program.command("init").argument("[remote]", "the remote to use", "https://gitlab.com/bitspur/multiplatform.one/cookiecutter").option("--name <name>", "the name of the project").description("init multiplatform.one").action(async (remote) => {
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 = {
@@ -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", [
@@ -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.30",
3
+ "version": "1.0.32",
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.15"
55
+ "@multiplatform.one/utils": "^0.0.17"
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "^9.5.0",
@@ -20,10 +20,10 @@
20
20
  */
21
21
 
22
22
  import fs from 'fs/promises';
23
+ import fsSync from 'fs';
23
24
  import inquirer from 'inquirer';
24
25
  import os from 'os';
25
26
  import path from 'path';
26
- import pkg from '@multiplatform.one/cli/package.json';
27
27
  import type { CookieCutterConfig } from '../types';
28
28
  import { execa } from 'execa';
29
29
  import { fileURLToPath } from 'url';
@@ -31,7 +31,11 @@ import { program } from 'commander';
31
31
 
32
32
  process.env.COOKIECUTTER = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/cookiecutter.sh');
33
33
  program.name('multiplatform.one');
34
- program.version(pkg.version);
34
+ program.version(
35
+ JSON.parse(
36
+ fsSync.readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../package.json'), 'utf8'),
37
+ )?.version,
38
+ );
35
39
 
36
40
  program
37
41
  .command('init')
@@ -39,7 +43,7 @@ program
39
43
  .option('--name <name>', 'the name of the project')
40
44
  .description('init multiplatform.one')
41
45
  .action(async (remote) => {
42
- 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) {
43
47
  throw new Error('multiplatform.one cannot be initialized inside a git repository');
44
48
  }
45
49
  const cookieCutterConfig: CookieCutterConfig = {
@@ -77,10 +81,16 @@ program
77
81
  .argument('[remote]', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
78
82
  .description('update multiplatform.one')
79
83
  .action(async (remote) => {
80
- 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) {
81
85
  throw new Error('multiplatform.one cannot be updated outside of a git repository');
82
86
  }
83
- 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
+ ) {
84
94
  throw new Error('multiplatform.one cannot be updated with uncommitted changes');
85
95
  }
86
96
  const projectRoot = (await execa('git', ['rev-parse', '--show-toplevel'])).stdout.trim();
@@ -108,8 +118,8 @@ program
108
118
  remote,
109
119
  ],
110
120
  {
111
- stdio: 'inherit',
112
121
  cwd: projectRoot,
122
+ stdio: 'inherit',
113
123
  },
114
124
  );
115
125
  });