@ovipakla/gm-cli 2.1.3 → 2.2.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
 
@@ -279,8 +293,9 @@ program
279
293
  return process.exit(1);
280
294
  }
281
295
 
282
- const packageGM = getPackageGM()
283
- const scriptData = packageGM.data.scripts[foo]
296
+ const[packageFile, envFile] = parseProgramOptions();
297
+ const packageGM = getPackageGM(packageFile);
298
+ const scriptData = packageGM.data.scripts[foo];
284
299
  if (typeof scriptData !== 'string') {
285
300
  console.log(`script ${foo} wasn't found`);
286
301
  console.log(`Exited with code 1`);
@@ -288,7 +303,7 @@ program
288
303
  }
289
304
 
290
305
  const shellScript = `#!/bin/bash
291
- cd ${path.dirname(packageGM.file).replaceAll("\\", "/")}
306
+ cd ${sanitizePath(path.dirname(packageGM.file))}
292
307
 
293
308
  ${scriptData}
294
309
  `;
@@ -302,7 +317,7 @@ program
302
317
  function getFilesRecursively(dir, root) {
303
318
  let files = [];
304
319
  for (const entry of fs.readdirSync(dir)) {
305
- const fullPath = path.join(dir, entry).replaceAll("\\", "/");
320
+ const fullPath = sanitizePath(path.join(dir, entry));
306
321
  if (fs.statSync(fullPath).isDirectory()) {
307
322
  files = files.concat(getFilesRecursively(fullPath, root));
308
323
  } else {
@@ -333,28 +348,24 @@ program
333
348
  return result;
334
349
  }
335
350
 
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("\\", "/");
351
+ const [packageFile, _envFile] = parseProgramOptions();
352
+ const packageGM = getPackageGM(packageFile);
353
+ /*
354
+ const envFile = _envFile
355
+ ?? findFileUpwardsSync(".gm-cli.env")
356
+ ?? (() => { throw new Error('❌ .gm-cli.env was not found') })();
357
+ const envPath = sanitizePath(path.dirname(envFile));
348
358
  const envMap = parseEnvFile(envFile);
349
- const projectPath = path.dirname(path.join(path.dirname(packageGM.file), packageGM.data.main.replaceAll("\\", "/")));
359
+ */
360
+ const projectPath = path.dirname(path.join(path.dirname(packageGM.file), sanitizePath(packageGM.data.main)));
350
361
  const yypPath = getYYPPathFromPackageGM(packageGM)
351
362
  const yypOldPath = `${yypPath}.old`
352
363
  const yyp = fs.readFileSync(yypPath, "utf8");
353
364
  console.log(`📝 Backup yyp:`, yypOldPath);
354
365
  fs.copyFileSync(yypPath, yypOldPath);
355
366
 
356
- const datafilesPath = path.join(projectPath, "datafiles").replaceAll("\\", "/")
357
- const datafiles = getFilesRecursively(datafilesPath, datafilesPath)
367
+ const datafilesPath = sanitizePath(path.join(projectPath, "datafiles"));
368
+ const datafiles = getFilesRecursively(datafilesPath, datafilesPath);
358
369
  const replaced = yyp.replace(/"IncludedFiles"\s*:\s*\[(.*?)\]/s, `"IncludedFiles":[
359
370
  ${datafiles.join("\n ")}
360
371
  ]`);
@@ -372,7 +383,8 @@ program
372
383
  .option('-c, --clean', 'make clean build')
373
384
  .option('-p, --projectool', 'Path to ProjectTool.exe')
374
385
  .action(function() {
375
- const packageGM = getPackageGM()
386
+ const [packageFile, envFile] = parseProgramOptions();
387
+ const packageGM = getPackageGM(packageFile)
376
388
  const targetMap = new Map([ [ 'windows', 'win' ] ])
377
389
  const options = this.opts();
378
390
  const config = {
@@ -383,8 +395,9 @@ program
383
395
  launch: 'PackageZip',
384
396
  name: packageGM.data.name,
385
397
  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("\\", "/"),
398
+ yyp: sanitizePath(path.basename(packageGM.data.main)),
399
+ path: sanitizePath(path.join(path.dirname(packageGM.file), path.dirname(packageGM.data.main))),
400
+ env: envFile ?? '',
388
401
  };
389
402
 
390
403
  if (options.runtime !== undefined) {
@@ -423,19 +436,26 @@ program
423
436
  echo -e "\\\e[90m$timestamp\\\e[0m \\\e[31mERROR\\\e[0m \\\e[35m[gm-cli::make]\\\e[0m $1"
424
437
  }
425
438
 
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
439
+ gm_cli_env_path="${config.env}"
440
+ if [ -z "$gm_cli_env_path" ]; then
441
+ dir=$(realpath "$PWD")
442
+ while [ "$dir" != "/" ]; do
443
+ if [ -f "$dir/.gm-cli.env" ]; then
444
+ gm_cli_env_path="$dir/.gm-cli.env"
445
+ log_info "Load configuration '$gm_cli_env_path'"
446
+ set -a
447
+ . "$gm_cli_env_path"
448
+ set +a
449
+ break
450
+ fi
451
+ dir=$(dirname "$dir")
452
+ done
453
+ else
454
+ log_info "Load configuration '$gm_cli_env_path'"
455
+ set -a
456
+ . "$gm_cli_env_path"
457
+ set +a
458
+ fi
439
459
 
440
460
  runtime_path=$GM_CLI_RUNTIME_PATH
441
461
  if [ -z "$runtime_path" ]; then
@@ -573,7 +593,8 @@ program
573
593
  GM_CLI_VS_DEV_CMD_PATH: path.normalize(propertyVsDevCmdPath),
574
594
  };
575
595
 
576
- const filePath = path.join(projectPath, '.gm-cli.env');
596
+ const [packageFile, envFile] = parseProgramOptions();
597
+ const filePath = envFile ?? path.join(projectPath, '.gm-cli.env');
577
598
  const dataString = Object.entries(data)
578
599
  .map(([key, value]) => `${key}="${value}"`)
579
600
  .join("\n");
@@ -600,7 +621,8 @@ program
600
621
  .option('-n, --name <name>', 'name of binary')
601
622
  .option('-r, --report <report>', 'name of CSV report file')
602
623
  .action((options) => {
603
- const packageGM = getPackageGM()
624
+ const [packageFile, envFile] = parseProgramOptions();
625
+ const packageGM = getPackageGM(packageFile);
604
626
  const interval = clamp((Number.isNaN(Number(options.interval)) ? 15.0 : Number(options.interval)), 1.0 / 60.0, 999.0)
605
627
  const name = options.name === undefined ? packageGM.data.name : options.name
606
628
  const report = options.report === undefined ? '' : options.report
@@ -631,7 +653,8 @@ program
631
653
  .option('-b, --build <build>', 'Path to executable')
632
654
  .option('-m, --monitorRAM', 'Monitor RAM while testing')
633
655
  .action((options) => {
634
- const packageGM = getPackageGM()
656
+ const [packageFile, envFile] = parseProgramOptions();
657
+ const packageGM = getPackageGM(packageFile);
635
658
 
636
659
  const shellMonitorRAMScript = options.monitorRAM === undefined ? `` : `
637
660
  set -m
@@ -641,7 +664,7 @@ program
641
664
  `;
642
665
 
643
666
  const shellBuildScript = options.build !== undefined ? `
644
- cd ${path.dirname(options.build).replaceAll("\\", "/")}
667
+ cd ${sanitizePath(path.dirname(options.build))}
645
668
  build_name="\$\{PWD##*/\}"
646
669
 
647
670
  EXE_FILE="${path.basename(options.build)}"
@@ -679,7 +702,7 @@ program
679
702
  `;
680
703
 
681
704
  const shellScript = `#!/bin/bash
682
- cd ${path.dirname(packageGM.file).replaceAll("\\", "/")}
705
+ cd ${sanitizePath(path.dirname(packageGM.file))}
683
706
 
684
707
  ${shellBuildScript}
685
708
 
@@ -712,7 +735,8 @@ configSet
712
735
  console.log("🔨 Set dependency", name, "as", packageGM.data.dependencies[name])
713
736
  };
714
737
 
715
- const packageGM = getPackageGM()
738
+ const [packageFile, envFile] = parseProgramOptions();
739
+ const packageGM = getPackageGM(packageFile);
716
740
 
717
741
  backupPackageGM(packageGM)
718
742
  resolve()
@@ -728,7 +752,8 @@ configSet
728
752
  console.log("🔨 Set script", name, "as", packageGM.data.scripts[name])
729
753
  }
730
754
 
731
- const packageGM = getPackageGM()
755
+ const [packageFile, envFile] = parseProgramOptions();
756
+ const packageGM = getPackageGM(packageFile);
732
757
 
733
758
  backupPackageGM(packageGM)
734
759
  resolve()
@@ -744,7 +769,8 @@ configSet
744
769
  console.log("🔨 Set runtime", name, "as", supported === "false" ? "false" : "true")
745
770
  }
746
771
 
747
- const packageGM = getPackageGM()
772
+ const [packageFile, envFile] = parseProgramOptions();
773
+ const packageGM = getPackageGM(packageFile);
748
774
 
749
775
  backupPackageGM(packageGM)
750
776
  resolve()
@@ -762,7 +788,8 @@ configUnset
762
788
  }
763
789
  }
764
790
 
765
- const packageGM = getPackageGM()
791
+ const [packageFile, envFile] = parseProgramOptions();
792
+ const packageGM = getPackageGM(packageFile);
766
793
 
767
794
  backupPackageGM(packageGM)
768
795
  resolve()
@@ -780,7 +807,8 @@ configUnset
780
807
  }
781
808
  }
782
809
 
783
- const packageGM = getPackageGM()
810
+ const [packageFile, envFile] = parseProgramOptions();
811
+ const packageGM = getPackageGM(packageFile);
784
812
 
785
813
  backupPackageGM(packageGM)
786
814
  resolve()
@@ -798,7 +826,8 @@ configUnset
798
826
  }
799
827
  }
800
828
 
801
- const packageGM = getPackageGM()
829
+ const [packageFile, envFile] = parseProgramOptions();
830
+ const packageGM = getPackageGM(packageFile);
802
831
 
803
832
  backupPackageGM(packageGM)
804
833
  resolve()
@@ -812,7 +841,8 @@ resource
812
841
  .requiredOption("-n, --name <name>", "Resource name")
813
842
  .option("-f, --folder <folder>", "Resource folder")
814
843
  .action((options) => {
815
- const packageGM = getPackageGM()
844
+ const [packageFile, envFile] = parseProgramOptions();
845
+ const packageGM = getPackageGM(packageFile);
816
846
  const yypPath = getYYPPathFromPackageGM(packageGM)
817
847
  const folderOption = options.folder !== undefined ? `folder=${options.folder}` : ``
818
848
  const shellScript = `yy-gm-cli resourcetool eval "resource create type=${options.type} name=${options.name} ${folderOption}" ${yypPath}`
@@ -825,7 +855,8 @@ resource
825
855
  .requiredOption("-e, --expr <expr>", "Resource expression")
826
856
  .requiredOption("-v, --value <value>", "New value")
827
857
  .action((options) => {
828
- const packageGM = getPackageGM()
858
+ const [packageFile, envFile] = parseProgramOptions();
859
+ const packageGM = getPackageGM(packageFile);
829
860
  const yypPath = getYYPPathFromPackageGM(packageGM)
830
861
  const shellScript = `yy-gm-cli resourcetool eval "resource set expr=${options.expr} value=${options.value}" ${yypPath}`
831
862
  runShellScript(shellScript)
@@ -833,10 +864,11 @@ resource
833
864
 
834
865
  resource
835
866
  .command("get")
836
- .description(" a resource")
867
+ .description("Get a resource")
837
868
  .requiredOption("-e, --expr <expr>", "Resource expression")
838
869
  .action((options) => {
839
- const packageGM = getPackageGM()
870
+ const [packageFile, envFile] = parseProgramOptions();
871
+ const packageGM = getPackageGM(packageFile);
840
872
  const yypPath = getYYPPathFromPackageGM(packageGM)
841
873
  const shellScript = `yy-gm-cli resourcetool eval "resource info expr=${options.expr}" ${yypPath}`
842
874
  runShellScript(shellScript)
@@ -848,7 +880,8 @@ resource
848
880
  .requiredOption("-n, --name <name>", "Resource name")
849
881
  .option("--type <type>", "Resource type")
850
882
  .action((options) => {
851
- const packageGM = getPackageGM()
883
+ const [packageFile, envFile] = parseProgramOptions();
884
+ const packageGM = getPackageGM(packageFile)
852
885
  const yypPath = getYYPPathFromPackageGM(packageGM)
853
886
  const typeOptions = options.type !== undefined ? `type=${options.type}` : ``
854
887
  const shellScript = `yy-gm-cli resourcetool eval "resource delete name=${options.name} ${typeOptions}" ${yypPath}`
@@ -860,7 +893,8 @@ resource
860
893
  .description("List resources")
861
894
  .option("--type <type>", "Resource type")
862
895
  .action((options) => {
863
- const packageGM = getPackageGM()
896
+ const [packageFile, envFile] = parseProgramOptions();
897
+ const packageGM = getPackageGM(packageFile)
864
898
  const yypPath = getYYPPathFromPackageGM(packageGM)
865
899
  const typeOptions = options.type !== undefined ? `type=${options.type}` : ``
866
900
  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.2.0",
7
7
  "description": "Gamemaker CLI toolkit. Watch &amp; sync gml sources with yyp project.",
8
8
  "main": "app.js",
9
9
  "scripts": {},