@ovipakla/gm-cli 2.1.3 → 2.3.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.
package/Jenkinsfile ADDED
@@ -0,0 +1,25 @@
1
+ pipeline {
2
+ agent any
3
+
4
+ options {
5
+ timeout(time: 60, unit: 'MINUTES')
6
+ buildDiscarder(logRotator(numToKeepStr: '14'))
7
+ }
8
+
9
+ stages {
10
+ stage('Verify gm-cli') {
11
+ steps {
12
+ script {
13
+ def buildJob = build(
14
+ job: 'gm-cli/verify',
15
+ propagate: true,
16
+ wait: true,
17
+ parameters: [
18
+ string(name: 'GIT_REVISION', value: "${env.GIT_COMMIT}"),
19
+ ]
20
+ )
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Alkapivo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Alkapivo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # gm-cli
2
- Gamemaker CLI toolkit. Watch & sync gml sources with yyp project.
3
-
4
- # Requirements
5
- - [Node.js](https://nodejs.org) 18.16^
6
- - [find](https://en.wikipedia.org/wiki/Find_(Unix))
7
-
8
- # Install
9
- ```bash
10
- npm install -g
11
- ```
12
-
13
- # Usage
14
- ```bash
15
- gm-cli
16
- ```
1
+ # gm-cli
2
+ Gamemaker CLI toolkit. Watch & sync gml sources with yyp project.
3
+
4
+ # Requirements
5
+ - [Node.js](https://nodejs.org) 18.16^
6
+ - [find](https://en.wikipedia.org/wiki/Find_(Unix))
7
+
8
+ # Install
9
+ ```bash
10
+ npm install -g
11
+ ```
12
+
13
+ # Usage
14
+ ```bash
15
+ gm-cli
16
+ ```
package/app.js CHANGED
@@ -8,6 +8,22 @@ import fs from 'fs';
8
8
  import readline from 'readline';
9
9
  import { fileURLToPath } from "node:url";
10
10
 
11
+
12
+ ///@return {[ string | undefined, string | undefined ]}
13
+ function parseProgramOptions() {
14
+ const options = program.opts();
15
+ return [ options.package, options.env ]
16
+ }
17
+
18
+ ///@params {string} path
19
+ ///@return {string}
20
+ function sanitizePath(path) {
21
+ return path.replaceAll("\\", "/")
22
+ }
23
+
24
+ ///@params {string} filename
25
+ ///@params {integer} maxLevels
26
+ ///@return {string | null}
11
27
  function findFileUpwardsSync(filename, maxLevels = 99) {
12
28
  let currentDir = process.cwd();
13
29
  for (let i = 0; i < maxLevels; i++) {
@@ -27,31 +43,40 @@ function findFileUpwardsSync(filename, maxLevels = 99) {
27
43
  return null;
28
44
  }
29
45
 
30
- function getPackageGM() {
31
- const file = findFileUpwardsSync("package-gm.json");
32
- if (file === null) {
33
- throw new Error('❌ package-gm.json was not found')
34
- }
35
-
46
+ ///@params {string | undefined}
47
+ ///@return {Object}
48
+ function getPackageGM(packageFile = undefined) {
49
+ const file = packageFile
50
+ ?? findFileUpwardsSync("package-gm.json")
51
+ ?? (() => { throw new Error('❌ package-gm.json was not found') })();
52
+
36
53
  return {
37
54
  file: file,
38
55
  data: JSON.parse(fs.readFileSync(file, "utf8")),
39
56
  }
40
57
  }
41
58
 
59
+ ///@params {Object} packageGM
60
+ ///@return {string}
42
61
  function getYYPPathFromPackageGM(packageGM) {
43
- return path.join(path.dirname(packageGM.file), packageGM.data.main).replaceAll("\\", "/");
62
+ return sanitizePath(path.join(path.dirname(packageGM.file), packageGM.data.main));
44
63
  }
45
64
 
65
+ ///@params {Object} packageGM
46
66
  function backupPackageGM(packageGM) {
47
67
  console.log(`📝 Backup package-gm.json: ${packageGM.file}.old`);
48
68
  fs.copyFileSync(packageGM.file, `${packageGM.file}.old`);
49
69
  }
50
70
 
71
+ ///@params {Object} packageGM
51
72
  function savePackageGM(packageGM) {
52
73
  fs.writeFileSync(packageGM.file, JSON.stringify(packageGM.data, null, 2), "utf8");
53
74
  }
54
75
 
76
+ ///@params {number} value
77
+ ///@params {number} min
78
+ ///@params {number} max
79
+ ///@return P
55
80
  function clamp(value, min, max) {
56
81
  return Math.min(Math.max(value, min), max);
57
82
  }
@@ -106,7 +131,9 @@ function runShellScript(scriptData) {
106
131
  const packageJson = JSON.parse(fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "package.json"), "utf-8"));
107
132
 
108
133
  const program = new Command()
109
- .version(packageJson.version, '-v, --version, ', 'output the current version');
134
+ .version(packageJson.version, '-v, --version, ', 'output the current version')
135
+ .option('-P, --package <package>', 'package file')
136
+ .option('-E, --env <env>', 'environment');
110
137
 
111
138
  const config = program
112
139
  .command('config')
@@ -124,7 +151,6 @@ const resource = program
124
151
  .command("resource")
125
152
  .description("Manage resources");
126
153
 
127
-
128
154
  program
129
155
  .command('init')
130
156
  .description('CLI creator for package-gm.json')
@@ -170,8 +196,9 @@ program
170
196
  dependencies: {},
171
197
  runtimes: {},
172
198
  };
173
-
174
- const filePath = path.join(projectPath, 'package-gm.json');
199
+
200
+ const[packageFile, envFile] = parseProgramOptions();
201
+ const filePath = path.join(projectPath, packageFile ?? 'package-gm.json');
175
202
  const dataString = JSON.stringify(data, null, 2);
176
203
 
177
204
  console.log(`About to write to ${filePath}:\n\n${dataString}\n\n`);
@@ -193,14 +220,16 @@ program
193
220
  .command('watch')
194
221
  .description('Watch modules dir and copy code to gamemaker project')
195
222
  .action(() => {
196
- watch(path.normalize(path.join(process.cwd(), 'package-gm.json')))
223
+ const[packageFile, envFile] = parseProgramOptions();
224
+ watch(path.normalize(path.join(process.cwd(), packageFile ?? 'package-gm.json')))
197
225
  });
198
226
 
199
227
  program
200
228
  .command('sync')
201
229
  .description('Copy code from modules dir to gamemaker project')
202
230
  .action(() => {
203
- sync(path.normalize(path.join(process.cwd(), 'package-gm.json')))
231
+ const[packageFile, envFile] = parseProgramOptions();
232
+ sync(path.normalize(path.join(process.cwd(), packageFile ?? 'package-gm.json')))
204
233
  });
205
234
 
206
235
  program
@@ -221,46 +250,31 @@ program
221
250
  fs.mkdirSync(modulesDir);
222
251
  }
223
252
 
224
- const packageGM = getPackageGM()
253
+ const [packageFile, envFile] = parseProgramOptions();
254
+ const packageGM = getPackageGM(packageFile)
225
255
  const dependencies = packageGM.data.dependencies;
226
256
  Object.entries(dependencies).forEach(([key, dependency]) => {
227
257
  console.log(`\n📦️ Install ${key}\n===========${"=".repeat(key.length)}`)
228
- const modulePath = path.join(modulesDir, key).replaceAll("\\", "/");
258
+ const modulePath = path.join(modulesDir, key);
229
259
  const cloneOptions = shallow ? `--depth 1 --branch ${dependency.revision}` : ''
230
- const fetchOptions = shallow ? `origin "${dependency.revision}"` : `--all --tags`
231
- const commit = `
232
- COMMIT="${dependencies.revision}"
233
- if git rev-parse --verify "${dependency.revision}^{commit}" >/dev/null 2>&1; then
234
- COMMIT=\$(git rev-parse "${dependency.revision}^{commit}")
235
- elif git rev-parse --verify "origin/${dependency.revision}^{commit}" >/dev/null 2>&1; then
236
- COMMIT=\$(git rev-parse "origin/${dependency.revision}^{commit}")
237
- else
238
- echo "Cannot resolve revision ${dependency.revision}"
239
- exit 1
240
- fi
241
-
242
- `
243
260
  if (fs.existsSync(modulePath)) {
244
261
  try {
245
- execSync('git rev-parse --is-inside-work-tree', { shell: "bash", cwd: modulePath, stdio: 'ignore' });
262
+ execSync('git rev-parse --is-inside-work-tree', { cwd: modulePath, stdio: 'ignore' });
246
263
  console.log(`🌐 Syncing ${modulePath} to revision ${dependency.revision}`);
247
- execSync(`git fetch ${fetchOptions}`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
248
- execSync(`${commit}git checkout --detach --force \$COMMIT`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
249
- execSync(`${commit}git reset --hard \$COMMIT`, { shell: "bash", cwd: modulePath, stdio: 'ignore' });
250
- execSync(`git clean -fd`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
264
+ execSync('git reset --hard HEAD', { cwd: modulePath, stdio: 'inherit' });
265
+ execSync('git clean -fdx', { cwd: modulePath, stdio: 'inherit' });
266
+ execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
251
267
  } catch (error) {
252
- console.log(`🗑️ Removing ${modulePath} because it's not a git repository`);
268
+ console.log(`🗑️ Removing ${modulePath} because it's not a git repository`);
253
269
  fs.rmSync(modulePath, { recursive: true, force: true });
254
270
  console.log(`🔧 Initializing ${modulePath} to revision ${dependency.revision}`);
255
- execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { shell: "bash", stdio: 'inherit' });
256
- execSync(`git fetch ${fetchOptions}`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
257
- execSync(`${commit}git checkout --detach --force \$COMMIT`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
271
+ execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
272
+ execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
258
273
  }
259
274
  } else {
260
275
  console.log(`🔧 Initializing ${modulePath} to revision ${dependency.revision}`);
261
- execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { shell: "bash", stdio: 'inherit' });
262
- execSync(`git fetch ${fetchOptions}`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
263
- execSync(`${commit}git checkout --detach --force \$COMMIT`, { shell: "bash", cwd: modulePath, stdio: 'inherit' });
276
+ execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
277
+ execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
264
278
  }
265
279
  });
266
280
 
@@ -272,25 +286,29 @@ program
272
286
  .command('run')
273
287
  .description('Run the script named <foo>')
274
288
  .argument('<foo>', 'script name')
275
- .action((foo) => {
289
+ .argument('[args...]', 'arguments to pass to the script')
290
+ .action((foo, args) => {
276
291
  if (typeof foo !== 'string') {
277
292
  console.log(`missing argument`);
278
293
  console.log(`Exited with code 1`);
279
294
  return process.exit(1);
280
295
  }
281
296
 
282
- const packageGM = getPackageGM()
283
- const scriptData = packageGM.data.scripts[foo]
297
+ const[packageFile, envFile] = parseProgramOptions();
298
+ const packageGM = getPackageGM(packageFile);
299
+ const scriptData = packageGM.data.scripts[foo];
284
300
  if (typeof scriptData !== 'string') {
285
301
  console.log(`script ${foo} wasn't found`);
286
302
  console.log(`Exited with code 1`);
287
303
  return process.exit(1);
288
304
  }
289
305
 
306
+ const scriptArgs = args.join(' ');
307
+
290
308
  const shellScript = `#!/bin/bash
291
- cd ${path.dirname(packageGM.file).replaceAll("\\", "/")}
309
+ cd ${sanitizePath(path.dirname(packageGM.file))}
292
310
 
293
- ${scriptData}
311
+ ${scriptData} ${scriptArgs}
294
312
  `;
295
313
  runShellScript(shellScript)
296
314
  });
@@ -302,7 +320,7 @@ program
302
320
  function getFilesRecursively(dir, root) {
303
321
  let files = [];
304
322
  for (const entry of fs.readdirSync(dir)) {
305
- const fullPath = path.join(dir, entry).replaceAll("\\", "/");
323
+ const fullPath = sanitizePath(path.join(dir, entry));
306
324
  if (fs.statSync(fullPath).isDirectory()) {
307
325
  files = files.concat(getFilesRecursively(fullPath, root));
308
326
  } else {
@@ -333,28 +351,24 @@ program
333
351
  return result;
334
352
  }
335
353
 
336
- const envFile = findFileUpwardsSync(".gm-cli.env");
337
- if (envFile === null) {
338
- console.error('.gm-cli.env was not found')
339
- return
340
- }
341
-
342
- const packageGM = getPackageGM()
343
- if (packageGM === null) {
344
- return null
345
- }
346
-
347
- const envPath = path.dirname(envFile).replaceAll("\\", "/");
354
+ const [packageFile, _envFile] = parseProgramOptions();
355
+ const packageGM = getPackageGM(packageFile);
356
+ /*
357
+ const envFile = _envFile
358
+ ?? findFileUpwardsSync(".gm-cli.env")
359
+ ?? (() => { throw new Error('❌ .gm-cli.env was not found') })();
360
+ const envPath = sanitizePath(path.dirname(envFile));
348
361
  const envMap = parseEnvFile(envFile);
349
- const projectPath = path.dirname(path.join(path.dirname(packageGM.file), packageGM.data.main.replaceAll("\\", "/")));
362
+ */
363
+ const projectPath = path.dirname(path.join(path.dirname(packageGM.file), sanitizePath(packageGM.data.main)));
350
364
  const yypPath = getYYPPathFromPackageGM(packageGM)
351
365
  const yypOldPath = `${yypPath}.old`
352
366
  const yyp = fs.readFileSync(yypPath, "utf8");
353
367
  console.log(`📝 Backup yyp:`, yypOldPath);
354
368
  fs.copyFileSync(yypPath, yypOldPath);
355
369
 
356
- const datafilesPath = path.join(projectPath, "datafiles").replaceAll("\\", "/")
357
- const datafiles = getFilesRecursively(datafilesPath, datafilesPath)
370
+ const datafilesPath = sanitizePath(path.join(projectPath, "datafiles"));
371
+ const datafiles = getFilesRecursively(datafilesPath, datafilesPath);
358
372
  const replaced = yyp.replace(/"IncludedFiles"\s*:\s*\[(.*?)\]/s, `"IncludedFiles":[
359
373
  ${datafiles.join("\n ")}
360
374
  ]`);
@@ -372,7 +386,8 @@ program
372
386
  .option('-c, --clean', 'make clean build')
373
387
  .option('-p, --projectool', 'Path to ProjectTool.exe')
374
388
  .action(function() {
375
- const packageGM = getPackageGM()
389
+ const [packageFile, envFile] = parseProgramOptions();
390
+ const packageGM = getPackageGM(packageFile)
376
391
  const targetMap = new Map([ [ 'windows', 'win' ] ])
377
392
  const options = this.opts();
378
393
  const config = {
@@ -383,8 +398,9 @@ program
383
398
  launch: 'PackageZip',
384
399
  name: packageGM.data.name,
385
400
  zip: packageGM.data.name,
386
- yyp: path.basename(packageGM.data.main).replaceAll("\\", "/"),
387
- path: path.join(path.dirname(packageGM.file), path.dirname(packageGM.data.main)).replaceAll("\\", "/"),
401
+ yyp: sanitizePath(path.basename(packageGM.data.main)),
402
+ path: sanitizePath(path.join(path.dirname(packageGM.file), path.dirname(packageGM.data.main))),
403
+ env: envFile ?? '',
388
404
  };
389
405
 
390
406
  if (options.runtime !== undefined) {
@@ -423,19 +439,26 @@ program
423
439
  echo -e "\\\e[90m$timestamp\\\e[0m \\\e[31mERROR\\\e[0m \\\e[35m[gm-cli::make]\\\e[0m $1"
424
440
  }
425
441
 
426
- gm_cli_env_path=""
427
- dir=$(realpath "$PWD")
428
- while [ "$dir" != "/" ]; do
429
- if [ -f "$dir/.gm-cli.env" ]; then
430
- gm_cli_env_path="$dir/.gm-cli.env"
431
- log_info "Load configuration '$gm_cli_env_path'"
432
- set -a
433
- . "$gm_cli_env_path"
434
- set +a
435
- break
436
- fi
437
- dir=$(dirname "$dir")
438
- done
442
+ gm_cli_env_path="${config.env}"
443
+ if [ -z "$gm_cli_env_path" ]; then
444
+ dir=$(realpath "$PWD")
445
+ while [ "$dir" != "/" ]; do
446
+ if [ -f "$dir/.gm-cli.env" ]; then
447
+ gm_cli_env_path="$dir/.gm-cli.env"
448
+ log_info "Load configuration '$gm_cli_env_path'"
449
+ set -a
450
+ . "$gm_cli_env_path"
451
+ set +a
452
+ break
453
+ fi
454
+ dir=$(dirname "$dir")
455
+ done
456
+ else
457
+ log_info "Load configuration '$gm_cli_env_path'"
458
+ set -a
459
+ . "$gm_cli_env_path"
460
+ set +a
461
+ fi
439
462
 
440
463
  runtime_path=$GM_CLI_RUNTIME_PATH
441
464
  if [ -z "$runtime_path" ]; then
@@ -573,7 +596,8 @@ program
573
596
  GM_CLI_VS_DEV_CMD_PATH: path.normalize(propertyVsDevCmdPath),
574
597
  };
575
598
 
576
- const filePath = path.join(projectPath, '.gm-cli.env');
599
+ const [packageFile, envFile] = parseProgramOptions();
600
+ const filePath = envFile ?? path.join(projectPath, '.gm-cli.env');
577
601
  const dataString = Object.entries(data)
578
602
  .map(([key, value]) => `${key}="${value}"`)
579
603
  .join("\n");
@@ -600,7 +624,8 @@ program
600
624
  .option('-n, --name <name>', 'name of binary')
601
625
  .option('-r, --report <report>', 'name of CSV report file')
602
626
  .action((options) => {
603
- const packageGM = getPackageGM()
627
+ const [packageFile, envFile] = parseProgramOptions();
628
+ const packageGM = getPackageGM(packageFile);
604
629
  const interval = clamp((Number.isNaN(Number(options.interval)) ? 15.0 : Number(options.interval)), 1.0 / 60.0, 999.0)
605
630
  const name = options.name === undefined ? packageGM.data.name : options.name
606
631
  const report = options.report === undefined ? '' : options.report
@@ -631,7 +656,8 @@ program
631
656
  .option('-b, --build <build>', 'Path to executable')
632
657
  .option('-m, --monitorRAM', 'Monitor RAM while testing')
633
658
  .action((options) => {
634
- const packageGM = getPackageGM()
659
+ const [packageFile, envFile] = parseProgramOptions();
660
+ const packageGM = getPackageGM(packageFile);
635
661
 
636
662
  const shellMonitorRAMScript = options.monitorRAM === undefined ? `` : `
637
663
  set -m
@@ -641,7 +667,7 @@ program
641
667
  `;
642
668
 
643
669
  const shellBuildScript = options.build !== undefined ? `
644
- cd ${path.dirname(options.build).replaceAll("\\", "/")}
670
+ cd ${sanitizePath(path.dirname(options.build))}
645
671
  build_name="\$\{PWD##*/\}"
646
672
 
647
673
  EXE_FILE="${path.basename(options.build)}"
@@ -679,7 +705,7 @@ program
679
705
  `;
680
706
 
681
707
  const shellScript = `#!/bin/bash
682
- cd ${path.dirname(packageGM.file).replaceAll("\\", "/")}
708
+ cd ${sanitizePath(path.dirname(packageGM.file))}
683
709
 
684
710
  ${shellBuildScript}
685
711
 
@@ -712,7 +738,8 @@ configSet
712
738
  console.log("🔨 Set dependency", name, "as", packageGM.data.dependencies[name])
713
739
  };
714
740
 
715
- const packageGM = getPackageGM()
741
+ const [packageFile, envFile] = parseProgramOptions();
742
+ const packageGM = getPackageGM(packageFile);
716
743
 
717
744
  backupPackageGM(packageGM)
718
745
  resolve()
@@ -728,7 +755,8 @@ configSet
728
755
  console.log("🔨 Set script", name, "as", packageGM.data.scripts[name])
729
756
  }
730
757
 
731
- const packageGM = getPackageGM()
758
+ const [packageFile, envFile] = parseProgramOptions();
759
+ const packageGM = getPackageGM(packageFile);
732
760
 
733
761
  backupPackageGM(packageGM)
734
762
  resolve()
@@ -744,7 +772,8 @@ configSet
744
772
  console.log("🔨 Set runtime", name, "as", supported === "false" ? "false" : "true")
745
773
  }
746
774
 
747
- const packageGM = getPackageGM()
775
+ const [packageFile, envFile] = parseProgramOptions();
776
+ const packageGM = getPackageGM(packageFile);
748
777
 
749
778
  backupPackageGM(packageGM)
750
779
  resolve()
@@ -762,7 +791,8 @@ configUnset
762
791
  }
763
792
  }
764
793
 
765
- const packageGM = getPackageGM()
794
+ const [packageFile, envFile] = parseProgramOptions();
795
+ const packageGM = getPackageGM(packageFile);
766
796
 
767
797
  backupPackageGM(packageGM)
768
798
  resolve()
@@ -780,7 +810,8 @@ configUnset
780
810
  }
781
811
  }
782
812
 
783
- const packageGM = getPackageGM()
813
+ const [packageFile, envFile] = parseProgramOptions();
814
+ const packageGM = getPackageGM(packageFile);
784
815
 
785
816
  backupPackageGM(packageGM)
786
817
  resolve()
@@ -798,7 +829,8 @@ configUnset
798
829
  }
799
830
  }
800
831
 
801
- const packageGM = getPackageGM()
832
+ const [packageFile, envFile] = parseProgramOptions();
833
+ const packageGM = getPackageGM(packageFile);
802
834
 
803
835
  backupPackageGM(packageGM)
804
836
  resolve()
@@ -812,7 +844,8 @@ resource
812
844
  .requiredOption("-n, --name <name>", "Resource name")
813
845
  .option("-f, --folder <folder>", "Resource folder")
814
846
  .action((options) => {
815
- const packageGM = getPackageGM()
847
+ const [packageFile, envFile] = parseProgramOptions();
848
+ const packageGM = getPackageGM(packageFile);
816
849
  const yypPath = getYYPPathFromPackageGM(packageGM)
817
850
  const folderOption = options.folder !== undefined ? `folder=${options.folder}` : ``
818
851
  const shellScript = `yy-gm-cli resourcetool eval "resource create type=${options.type} name=${options.name} ${folderOption}" ${yypPath}`
@@ -825,7 +858,8 @@ resource
825
858
  .requiredOption("-e, --expr <expr>", "Resource expression")
826
859
  .requiredOption("-v, --value <value>", "New value")
827
860
  .action((options) => {
828
- const packageGM = getPackageGM()
861
+ const [packageFile, envFile] = parseProgramOptions();
862
+ const packageGM = getPackageGM(packageFile);
829
863
  const yypPath = getYYPPathFromPackageGM(packageGM)
830
864
  const shellScript = `yy-gm-cli resourcetool eval "resource set expr=${options.expr} value=${options.value}" ${yypPath}`
831
865
  runShellScript(shellScript)
@@ -833,10 +867,11 @@ resource
833
867
 
834
868
  resource
835
869
  .command("get")
836
- .description(" a resource")
870
+ .description("Get a resource")
837
871
  .requiredOption("-e, --expr <expr>", "Resource expression")
838
872
  .action((options) => {
839
- const packageGM = getPackageGM()
873
+ const [packageFile, envFile] = parseProgramOptions();
874
+ const packageGM = getPackageGM(packageFile);
840
875
  const yypPath = getYYPPathFromPackageGM(packageGM)
841
876
  const shellScript = `yy-gm-cli resourcetool eval "resource info expr=${options.expr}" ${yypPath}`
842
877
  runShellScript(shellScript)
@@ -848,7 +883,8 @@ resource
848
883
  .requiredOption("-n, --name <name>", "Resource name")
849
884
  .option("--type <type>", "Resource type")
850
885
  .action((options) => {
851
- const packageGM = getPackageGM()
886
+ const [packageFile, envFile] = parseProgramOptions();
887
+ const packageGM = getPackageGM(packageFile)
852
888
  const yypPath = getYYPPathFromPackageGM(packageGM)
853
889
  const typeOptions = options.type !== undefined ? `type=${options.type}` : ``
854
890
  const shellScript = `yy-gm-cli resourcetool eval "resource delete name=${options.name} ${typeOptions}" ${yypPath}`
@@ -860,7 +896,8 @@ resource
860
896
  .description("List resources")
861
897
  .option("--type <type>", "Resource type")
862
898
  .action((options) => {
863
- const packageGM = getPackageGM()
899
+ const [packageFile, envFile] = parseProgramOptions();
900
+ const packageGM = getPackageGM(packageFile)
864
901
  const yypPath = getYYPPathFromPackageGM(packageGM)
865
902
  const typeOptions = options.type !== undefined ? `type=${options.type}` : ``
866
903
  const shellScript = `yy-gm-cli resourcetool eval "resource list ${typeOptions}" ${yypPath}`
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.3",
6
+ "version": "2.3.0",
7
7
  "description": "Gamemaker CLI toolkit. Watch &amp; sync gml sources with yyp project.",
8
8
  "main": "app.js",
9
9
  "scripts": {},