@multiplatform.one/cli 1.0.37 → 1.0.38

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.
@@ -10,7 +10,7 @@ import { program } from "commander";
10
10
  process.env.COOKIECUTTER = `sh ${path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../scripts/cookiecutter.sh")}`;
11
11
  program.name("multiplatform.one");
12
12
  program.version(JSON.parse(fsSync.readFileSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json"), "utf8"))?.version);
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) => {
13
+ program.command("init").argument("[name]", "the name of the project", "").option("-r, --remote <remote>", "the remote to use", "https://gitlab.com/bitspur/multiplatform.one/cookiecutter").option("-c, --checkout <branch>", "branch, tag or commit to checkout", "main").description("init multiplatform.one").action(async (name, options) => {
14
14
  if ((await execa("git", [
15
15
  "rev-parse",
16
16
  "--is-inside-work-tree"
@@ -19,14 +19,17 @@ program.command("init").argument("[remote]", "the remote to use", "https://gitla
19
19
  })).exitCode === 0) {
20
20
  throw new Error("multiplatform.one cannot be initialized inside a git repository");
21
21
  }
22
- const cookieCutterConfig = {
23
- name: program.opts().name || (await inquirer.prompt([
22
+ if (!name) {
23
+ name = (await inquirer.prompt([
24
24
  {
25
25
  message: "What is the project name?",
26
26
  name: "name",
27
27
  type: "input"
28
28
  }
29
- ]))?.name
29
+ ])).name;
30
+ }
31
+ const cookieCutterConfig = {
32
+ name
30
33
  };
31
34
  const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), "multiplatform-")), "config.json");
32
35
  try {
@@ -37,7 +40,9 @@ program.command("init").argument("[remote]", "the remote to use", "https://gitla
37
40
  "-f",
38
41
  "--config-file",
39
42
  cookieCutterConfigFile,
40
- remote
43
+ "--checkout",
44
+ options.branch,
45
+ options.remote
41
46
  ], {
42
47
  stdio: "inherit"
43
48
  });
@@ -48,7 +53,7 @@ program.command("init").argument("[remote]", "the remote to use", "https://gitla
48
53
  });
49
54
  }
50
55
  });
51
- program.command("update").argument("[remote]", "the remote to use", "https://gitlab.com/bitspur/multiplatform.one/cookiecutter").description("update multiplatform.one").action(async (remote) => {
56
+ program.command("update").option("-r, --remote <remote>", "the remote to use", "https://gitlab.com/bitspur/multiplatform.one/cookiecutter").option("-c, --checkout <branch>", "branch, tag or commit to checkout", "main").description("update multiplatform.one").action(async (options) => {
52
57
  if ((await execa("git", [
53
58
  "rev-parse",
54
59
  "--is-inside-work-tree"
@@ -87,7 +92,9 @@ program.command("update").argument("[remote]", "the remote to use", "https://git
87
92
  "-f",
88
93
  "--config-file",
89
94
  cookieCutterConfigFile,
90
- remote
95
+ "--checkout",
96
+ options.branch,
97
+ options.remote
91
98
  ], {
92
99
  cwd: projectRoot,
93
100
  stdio: "inherit"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/cli",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "author": "BitSpur <support@bitspur.com> (https://bitspur.com)",
5
5
  "contributors": [
6
6
  {
@@ -39,26 +39,26 @@ program.version(
39
39
 
40
40
  program
41
41
  .command('init')
42
- .argument('[remote]', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
43
- .option('--name <name>', 'the name of the project')
42
+ .argument('[name]', 'the name of the project', '')
43
+ .option('-r, --remote <remote>', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
44
+ .option('-c, --checkout <branch>', 'branch, tag or commit to checkout', 'main')
44
45
  .description('init multiplatform.one')
45
- .action(async (remote) => {
46
+ .action(async (name, options) => {
46
47
  if ((await execa('git', ['rev-parse', '--is-inside-work-tree'], { reject: false })).exitCode === 0) {
47
48
  throw new Error('multiplatform.one cannot be initialized inside a git repository');
48
49
  }
49
- const cookieCutterConfig: CookieCutterConfig = {
50
- name:
51
- program.opts().name ||
52
- (
53
- await inquirer.prompt([
54
- {
55
- message: 'What is the project name?',
56
- name: 'name',
57
- type: 'input',
58
- },
59
- ])
60
- )?.name,
61
- };
50
+ if (!name) {
51
+ name = (
52
+ await inquirer.prompt([
53
+ {
54
+ message: 'What is the project name?',
55
+ name: 'name',
56
+ type: 'input',
57
+ },
58
+ ])
59
+ ).name;
60
+ }
61
+ const cookieCutterConfig: CookieCutterConfig = { name };
62
62
  const cookieCutterConfigFile = path.join(await fs.mkdtemp(path.join(os.tmpdir(), 'multiplatform-')), 'config.json');
63
63
  try {
64
64
  await fs.writeFile(cookieCutterConfigFile, JSON.stringify(cookieCutterConfig, null, 2));
@@ -70,7 +70,9 @@ program
70
70
  '-f',
71
71
  '--config-file',
72
72
  cookieCutterConfigFile,
73
- remote,
73
+ '--checkout',
74
+ options.branch,
75
+ options.remote,
74
76
  ],
75
77
  {
76
78
  stdio: 'inherit',
@@ -83,9 +85,10 @@ program
83
85
 
84
86
  program
85
87
  .command('update')
86
- .argument('[remote]', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
88
+ .option('-r, --remote <remote>', 'the remote to use', 'https://gitlab.com/bitspur/multiplatform.one/cookiecutter')
89
+ .option('-c, --checkout <branch>', 'branch, tag or commit to checkout', 'main')
87
90
  .description('update multiplatform.one')
88
- .action(async (remote) => {
91
+ .action(async (options) => {
89
92
  if ((await execa('git', ['rev-parse', '--is-inside-work-tree'], { reject: false })).exitCode !== 0) {
90
93
  throw new Error('multiplatform.one cannot be updated outside of a git repository');
91
94
  }
@@ -122,7 +125,9 @@ program
122
125
  '-f',
123
126
  '--config-file',
124
127
  cookieCutterConfigFile,
125
- remote,
128
+ '--checkout',
129
+ options.branch,
130
+ options.remote,
126
131
  ],
127
132
  {
128
133
  cwd: projectRoot,