@ovipakla/gm-cli 1.0.2 → 1.0.4

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/GMFileWatcher.js CHANGED
@@ -28,7 +28,7 @@ class GMModule {
28
28
  watcher: chokidar.watch(entry.dir, hook)
29
29
  }));
30
30
 
31
- console.log(`♻️ Watching [${dir}] for changes...`);
31
+ console.log(`🔍️ Watching [${dir}] for changes...`);
32
32
  }
33
33
 
34
34
  createWatcher(subdir, hook) {
@@ -299,7 +299,7 @@ class GMFileWatcher {
299
299
  const existing = fs.readFileSync(dst, 'utf8');
300
300
  if (existing !== script.content) {
301
301
  const result = removeZeroFields(diffStats(existing.split('\n'), script.content.split('\n')))
302
- console.log(`➡️ Save ${script.name}.${extension}:`, result);
302
+ console.log(`📝 Save ${script.name}.${extension}:`, result);
303
303
  fs.writeFileSync(dst, script.content, { encoding: 'utf8', flag: 'w' });
304
304
  }
305
305
 
package/app.js CHANGED
@@ -77,40 +77,50 @@ program.command('sync')
77
77
  });
78
78
  program.command('install')
79
79
  .description('Install dependencies listed in package-gm.json to gm_modules folder')
80
+ .option('-c, --clean', 'remove existing gm_modules')
81
+ .option('-s, --shallow', 'git clone will use depth=1 branch=REVISION')
80
82
  .action(function() {
83
+ const options = this.opts();
84
+ const clean = options.clean !== undefined;
85
+ const shallow = options.shallow !== undefined;
81
86
  const packageJsonPath = 'package-gm.json';
82
87
  const modulesDir = 'gm_modules';
83
88
 
84
89
  if (!fs.existsSync(modulesDir)) {
85
90
  fs.mkdirSync(modulesDir);
91
+ } else if (clean) {
92
+ fs.rmdirSync(modulesDir, { recursive: true });
93
+ fs.mkdirSync(modulesDir);
86
94
  }
87
95
 
88
96
  const packageData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
89
97
  const dependencies = packageData.dependencies;
90
98
  Object.entries(dependencies).forEach(([key, dependency]) => {
99
+ console.log(`\n📦️ Install ${key}\n===========${"=".repeat(key.length)}`)
91
100
  const modulePath = path.join(modulesDir, key);
101
+ const cloneOptions = shallow ? `--depth 1 --branch ${dependency.revision}` : ''
92
102
  if (fs.existsSync(modulePath)) {
93
103
  try {
94
104
  execSync('git rev-parse --is-inside-work-tree', { cwd: modulePath, stdio: 'ignore' });
95
- console.log(`Syncing ${modulePath} to revision ${dependency.revision}`);
105
+ console.log(`🌐 Syncing ${modulePath} to revision ${dependency.revision}`);
96
106
  execSync('git reset --hard HEAD', { cwd: modulePath, stdio: 'inherit' });
97
- execSync('git clean -fdx -e', { cwd: modulePath, stdio: 'inherit' });
107
+ execSync('git clean -fdx', { cwd: modulePath, stdio: 'inherit' });
98
108
  execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
99
109
  } catch (error) {
100
- console.log(`Removing ${modulePath} because it's not a git repository`);
110
+ console.log(`🗑️ Removing ${modulePath} because it's not a git repository`);
101
111
  fs.rmSync(modulePath, { recursive: true, force: true });
102
- console.log(`Initializing ${modulePath} to revision ${dependency.revision}`);
103
- execSync(`git clone ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
112
+ console.log(`🔧 Initializing ${modulePath} to revision ${dependency.revision}`);
113
+ execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
104
114
  execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
105
115
  }
106
116
  } else {
107
- console.log(`Initializing ${modulePath} to revision ${dependency.revision}`);
108
- execSync(`git clone ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
117
+ console.log(`🔧 Initializing ${modulePath} to revision ${dependency.revision}`);
118
+ execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
109
119
  execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
110
120
  }
111
121
  });
112
122
 
113
- console.log('All dependencies processed.');
123
+ console.log('\n\n✅ All dependencies processed.');
114
124
  process.exit(0);
115
125
  })
116
126
  program.command('run')
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.2",
6
+ "version": "1.0.4",
7
7
  "description": "Gamemaker CLI toolkit. Watch & sync gml sources with yyp project.",
8
8
  "main": "app.js",
9
9
  "scripts": {},