@backstage/cli-module-translations 0.1.1-next.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/cli-module-translations
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/cli-common@0.2.1
9
+ - @backstage/cli-node@0.3.1
10
+
3
11
  ## 0.1.1-next.0
4
12
 
5
13
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"messageFilePath.cjs.js","sources":["../../src/lib/messageFilePath.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// The default language for exported translation messages.\nexport const DEFAULT_LANGUAGE = 'en';\n\n// Default file path pattern for translation message files relative to the\n// translations directory. Supported placeholders: {id} and {lang}.\nexport const DEFAULT_MESSAGE_PATTERN = 'messages/{id}.{lang}.json';\n\n/** Formats a message file pattern into a concrete relative path. */\nexport function formatMessagePath(\n pattern: string,\n id: string,\n lang: string,\n): string {\n return pattern.replace(/\\{id\\}/g, id).replace(/\\{lang\\}/g, lang);\n}\n\n/** Creates a parser that extracts id and lang from a relative file path. */\nexport function createMessagePathParser(\n pattern: string,\n): (relativePath: string) => { id: string; lang: string } | undefined {\n validatePattern(pattern);\n\n // Build a regex from the pattern by escaping special chars and replacing\n // {id} and {lang} with named capture groups.\n const escaped = pattern\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/\\\\{id\\\\}/g, '(?<id>[^/]+)')\n .replace(/\\\\{lang\\\\}/g, '(?<lang>[a-z]{2})');\n\n const regex = new RegExp(`^${escaped}$`);\n\n return (relPath: string) => {\n const match = relPath.match(regex);\n if (!match?.groups) {\n return undefined;\n }\n return { id: match.groups.id, lang: match.groups.lang };\n };\n}\n\n/** Converts a message pattern into a glob string for discovering files. */\nexport function messagePatternToGlob(pattern: string): string {\n return pattern.replace(/\\{id\\}/g, '*').replace(/\\{lang\\}/g, '*');\n}\n\n/** Returns whether the pattern produces paths with subdirectories. */\nexport function patternHasSubdirectories(pattern: string): boolean {\n return pattern.includes('/');\n}\n\nexport function validatePattern(pattern: string) {\n if (!pattern.includes('{id}')) {\n throw new Error(\n `Invalid message file pattern: must contain {id} placeholder. Got: ${pattern}`,\n );\n }\n if (!pattern.includes('{lang}')) {\n throw new Error(\n `Invalid message file pattern: must contain {lang} placeholder. Got: ${pattern}`,\n );\n }\n if (!pattern.endsWith('.json')) {\n throw new Error(\n `Invalid message file pattern: must end with .json. Got: ${pattern}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,gBAAA,GAAmB;AAIzB,MAAM,uBAAA,GAA0B;AAGhC,SAAS,iBAAA,CACd,OAAA,EACA,EAAA,EACA,IAAA,EACQ;AACR,EAAA,OAAO,QAAQ,OAAA,CAAQ,SAAA,EAAW,EAAE,CAAA,CAAE,OAAA,CAAQ,aAAa,IAAI,CAAA;AACjE;AAGO,SAAS,wBACd,OAAA,EACoE;AACpE,EAAA,eAAA,CAAgB,OAAO,CAAA;AAIvB,EAAA,MAAM,OAAA,GAAU,OAAA,CACb,OAAA,CAAQ,qBAAA,EAAuB,MAAM,CAAA,CACrC,OAAA,CAAQ,WAAA,EAAa,cAAc,CAAA,CACnC,OAAA,CAAQ,aAAA,EAAe,mBAAmB,CAAA;AAE7C,EAAA,MAAM,KAAA,GAAQ,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,CAAG,CAAA;AAEvC,EAAA,OAAO,CAAC,OAAA,KAAoB;AAC1B,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AACjC,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,IAAI,KAAA,CAAM,MAAA,CAAO,IAAI,IAAA,EAAM,KAAA,CAAM,OAAO,IAAA,EAAK;AAAA,EACxD,CAAA;AACF;AAYO,SAAS,gBAAgB,OAAA,EAAiB;AAC/C,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA,EAAG;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,qEAAqE,OAAO,CAAA;AAAA,KAC9E;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA,EAAG;AAC/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uEAAuE,OAAO,CAAA;AAAA,KAChF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,2DAA2D,OAAO,CAAA;AAAA,KACpE;AAAA,EACF;AACF;;;;;;;;"}
1
+ {"version":3,"file":"messageFilePath.cjs.js","sources":["../../src/lib/messageFilePath.ts"],"sourcesContent":["/*\n * Copyright 2026 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// The default language for exported translation messages.\nexport const DEFAULT_LANGUAGE = 'en';\n\n// Default file path pattern for translation message files relative to the\n// translations directory. Supported placeholders: {id} and {lang}.\nexport const DEFAULT_MESSAGE_PATTERN = 'messages/{id}.{lang}.json';\n\n/** Formats a message file pattern into a concrete relative path. */\nexport function formatMessagePath(\n pattern: string,\n id: string,\n lang: string,\n): string {\n return pattern.replace(/\\{id\\}/g, id).replace(/\\{lang\\}/g, lang);\n}\n\n/** Creates a parser that extracts id and lang from a relative file path. */\nexport function createMessagePathParser(\n pattern: string,\n): (relativePath: string) => { id: string; lang: string } | undefined {\n validatePattern(pattern);\n\n // Build a regex from the pattern by escaping special chars and replacing\n // {id} and {lang} with named capture groups.\n const escaped = pattern\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/\\\\{id\\\\}/g, '(?<id>[^/]+)')\n .replace(/\\\\{lang\\\\}/g, '(?<lang>[a-z]{2})');\n\n const regex = new RegExp(`^${escaped}$`);\n\n return (relPath: string) => {\n const match = relPath.match(regex);\n if (!match?.groups) {\n return undefined;\n }\n return { id: match.groups.id, lang: match.groups.lang };\n };\n}\n\nexport function validatePattern(pattern: string) {\n if (!pattern.includes('{id}')) {\n throw new Error(\n `Invalid message file pattern: must contain {id} placeholder. Got: ${pattern}`,\n );\n }\n if (!pattern.includes('{lang}')) {\n throw new Error(\n `Invalid message file pattern: must contain {lang} placeholder. Got: ${pattern}`,\n );\n }\n if (!pattern.endsWith('.json')) {\n throw new Error(\n `Invalid message file pattern: must end with .json. Got: ${pattern}`,\n );\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,gBAAA,GAAmB;AAIzB,MAAM,uBAAA,GAA0B;AAGhC,SAAS,iBAAA,CACd,OAAA,EACA,EAAA,EACA,IAAA,EACQ;AACR,EAAA,OAAO,QAAQ,OAAA,CAAQ,SAAA,EAAW,EAAE,CAAA,CAAE,OAAA,CAAQ,aAAa,IAAI,CAAA;AACjE;AAGO,SAAS,wBACd,OAAA,EACoE;AACpE,EAAA,eAAA,CAAgB,OAAO,CAAA;AAIvB,EAAA,MAAM,OAAA,GAAU,OAAA,CACb,OAAA,CAAQ,qBAAA,EAAuB,MAAM,CAAA,CACrC,OAAA,CAAQ,WAAA,EAAa,cAAc,CAAA,CACnC,OAAA,CAAQ,aAAA,EAAe,mBAAmB,CAAA;AAE7C,EAAA,MAAM,KAAA,GAAQ,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,CAAG,CAAA;AAEvC,EAAA,OAAO,CAAC,OAAA,KAAoB;AAC1B,IAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AACjC,IAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,IAAI,KAAA,CAAM,MAAA,CAAO,IAAI,IAAA,EAAM,KAAA,CAAM,OAAO,IAAA,EAAK;AAAA,EACxD,CAAA;AACF;AAEO,SAAS,gBAAgB,OAAA,EAAiB;AAC/C,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA,EAAG;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,qEAAqE,OAAO,CAAA;AAAA,KAC9E;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA,EAAG;AAC/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uEAAuE,OAAO,CAAA;AAAA,KAChF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,2DAA2D,OAAO,CAAA;AAAA,KACpE;AAAA,EACF;AACF;;;;;;;;"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@backstage/cli-module-translations";
6
- var version = "0.1.1-next.0";
6
+ var version = "0.1.1";
7
7
  var description = "CLI module for Backstage CLI";
8
8
  var backstage = {
9
9
  role: "cli-module"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/cli-module-translations",
3
- "version": "0.1.1-next.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI module for Backstage CLI",
5
5
  "backstage": {
6
6
  "role": "cli-module"
@@ -32,14 +32,14 @@
32
32
  "test": "backstage-cli package test"
33
33
  },
34
34
  "dependencies": {
35
- "@backstage/cli-common": "0.2.1-next.0",
36
- "@backstage/cli-node": "0.3.1-next.0",
35
+ "@backstage/cli-common": "^0.2.1",
36
+ "@backstage/cli-node": "^0.3.1",
37
37
  "cleye": "^2.3.0",
38
38
  "fs-extra": "^11.2.0",
39
39
  "ts-morph": "^24.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@backstage/cli": "0.36.1-next.0",
42
+ "@backstage/cli": "^0.36.1",
43
43
  "@types/fs-extra": "^11.0.0"
44
44
  },
45
45
  "bin": "bin/backstage-cli-module-translations",