@orxataguy/tyr 1.0.42 → 1.0.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orxataguy/tyr",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tyr": "./bin/tyr.js"
@@ -41,8 +41,19 @@ function isValidHttpsUrl(value: string): boolean {
41
41
  }
42
42
  }
43
43
 
44
+ // Allows namespaced command names like 'db:migrate', but not a leading/
45
+ // trailing/doubled ':' (e.g. ':foo', 'foo:', 'a::b'), since those would
46
+ // produce an empty segment.
44
47
  function isValidCommandName(name: string): boolean {
45
- return /^[a-zA-Z0-9_-]+$/.test(name);
48
+ return /^[a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*$/.test(name);
49
+ }
50
+
51
+ // ':' is a valid character in a command name (namespacing, e.g. 'db:migrate')
52
+ // but isn't a safe filename component on every platform (Windows reserves it).
53
+ // Only used when deriving the on-disk file name — the real name with its
54
+ // colons is still what's stored in map.yml, the lockfile, and the manifest.
55
+ function toSafeFilename(commandName: string): string {
56
+ return commandName.replace(/:/g, '-');
46
57
  }
47
58
 
48
59
  function slugFromUrl(url: string): string {
@@ -183,14 +194,15 @@ export async function syncModules(context: TyrContext, options: { force?: boolea
183
194
  const content = await web.get(fileUrl);
184
195
  const fileContent = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
185
196
 
186
- const destPath = path.join(userRoot, 'commands', `${commandName}.tyr.ts`);
197
+ const fileName = toSafeFilename(commandName);
198
+ const destPath = path.join(userRoot, 'commands', `${fileName}.tyr.ts`);
187
199
  await fs.write(destPath, fileContent);
188
200
 
189
201
  if (managed && managed.module !== moduleName) {
190
202
  logger.warn(`'${commandName}' was previously managed by module '${managed.module}'; now owned by '${moduleName}'.`);
191
203
  }
192
204
 
193
- mapConfig.commands[commandName] = `./commands/${commandName}.tyr.ts`;
205
+ mapConfig.commands[commandName] = `./commands/${fileName}.tyr.ts`;
194
206
  lock.commands[commandName] = { module: moduleName, manifest: manifestUrl, source: fileUrl };
195
207
  mapChanged = true;
196
208
  lockChanged = true;