@vocab/cli 2.1.10 → 2.1.11
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/dist/index.cjs +41 -87
- package/dist/index.cjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
1
|
let _vocab_phrase = require("@vocab/phrase");
|
|
29
2
|
let _vocab_core = require("@vocab/core");
|
|
30
|
-
let yargs = require("yargs");
|
|
31
|
-
yargs = __toESM(yargs);
|
|
32
3
|
let node_child_process = require("node:child_process");
|
|
4
|
+
let commander = require("commander");
|
|
33
5
|
|
|
34
6
|
//#region src/getGitBranch.ts
|
|
35
7
|
function getGitBranch() {
|
|
@@ -45,68 +17,50 @@ function getGitBranch() {
|
|
|
45
17
|
}
|
|
46
18
|
}
|
|
47
19
|
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region package.json
|
|
22
|
+
var version = "2.1.11";
|
|
23
|
+
var description = "A CLI for generating typed Vocab translations and interacting with 3rd-party localization services";
|
|
24
|
+
|
|
48
25
|
//#endregion
|
|
49
26
|
//#region src/index.ts
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
const DEFAULT_BRANCH = getGitBranch() || "local-development";
|
|
28
|
+
const program = new commander.Command();
|
|
29
|
+
program.name("vocab").version(version).description(description).option("--config <path>", "Path to config file").hook("preAction", async (thisCommand, actionCommand) => {
|
|
30
|
+
const options = thisCommand.optsWithGlobals();
|
|
31
|
+
console.log("Loading configuration from", options.config || process.cwd());
|
|
32
|
+
const userConfig = await (0, _vocab_core.resolveConfig)(options.config);
|
|
33
|
+
if (!userConfig) throw new Error("No configuration file found");
|
|
34
|
+
console.log("Successfully loaded configuration");
|
|
35
|
+
actionCommand.setOptionValue("userConfig", userConfig);
|
|
36
|
+
});
|
|
37
|
+
const branchOption = new commander.Option("--branch", "The Phrase branch to target").default(DEFAULT_BRANCH);
|
|
38
|
+
const pushAction = async (options) => {
|
|
39
|
+
await (0, _vocab_phrase.push)({
|
|
40
|
+
branch: options.branch,
|
|
41
|
+
deleteUnusedKeys: options.deleteUnusedKeys,
|
|
42
|
+
ignore: options.ignore
|
|
43
|
+
}, options.userConfig);
|
|
54
44
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
program.command("push").description("Push translations to Phrase").addOption(branchOption).option("--delete-unused-keys", "Whether or not to delete unused keys after pushing", false).option("--ignore <paths...>", "Array of glob paths to ignore when searching for keys to push", []).action(pushAction);
|
|
46
|
+
const pullAction = async (options) => {
|
|
47
|
+
await (0, _vocab_phrase.pull)({
|
|
48
|
+
branch: options.branch,
|
|
49
|
+
errorOnNoGlobalKeyTranslation: options.errorOnNoGlobalKeyTranslation || false
|
|
50
|
+
}, options.userConfig);
|
|
60
51
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
console.log("
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
type: "boolean",
|
|
74
|
-
describe: "Whether or not to delete unused keys after pushing",
|
|
75
|
-
default: false
|
|
76
|
-
},
|
|
77
|
-
ignore: ignorePathDefinition
|
|
78
|
-
}),
|
|
79
|
-
handler: async (options) => {
|
|
80
|
-
await (0, _vocab_phrase.push)(options, config);
|
|
81
|
-
}
|
|
82
|
-
}).command({
|
|
83
|
-
command: "pull",
|
|
84
|
-
builder: (yargs$1) => yargs$1.options({
|
|
85
|
-
branch: branchDefinition,
|
|
86
|
-
"error-on-no-global-key-translation": {
|
|
87
|
-
type: "boolean",
|
|
88
|
-
describe: "Throw an error when there is no translation for a global key",
|
|
89
|
-
default: false
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
handler: async (options) => {
|
|
93
|
-
await (0, _vocab_phrase.pull)(options, config);
|
|
94
|
-
}
|
|
95
|
-
}).command({
|
|
96
|
-
command: "compile",
|
|
97
|
-
builder: (yargs$1) => yargs$1.options({ watch: {
|
|
98
|
-
type: "boolean",
|
|
99
|
-
default: false
|
|
100
|
-
} }),
|
|
101
|
-
handler: async ({ watch }) => {
|
|
102
|
-
await (0, _vocab_core.compile)({ watch }, config);
|
|
103
|
-
}
|
|
104
|
-
}).command({
|
|
105
|
-
command: "validate",
|
|
106
|
-
handler: async () => {
|
|
107
|
-
if (!await (0, _vocab_core.validate)(config)) throw new Error("Project invalid");
|
|
108
|
-
}
|
|
109
|
-
}).help().wrap(72).parse();
|
|
52
|
+
program.command("pull").description("Pull translations from Phrase").addOption(branchOption).option("--error-on-no-global-key-translation", "Throw an error when there is no translation for a global key", false).action(pullAction);
|
|
53
|
+
const compileAction = async (options) => {
|
|
54
|
+
await (0, _vocab_core.compile)({ watch: options.watch }, options.userConfig);
|
|
55
|
+
};
|
|
56
|
+
program.command("compile").description("Compile translations").option("--watch", "Watch for changes", false).action(compileAction);
|
|
57
|
+
const validateAction = async (options) => {
|
|
58
|
+
console.log("Validating project");
|
|
59
|
+
if (!await (0, _vocab_core.validate)(options.userConfig)) throw new Error("Project is invalid");
|
|
60
|
+
console.log("Project is valid");
|
|
61
|
+
};
|
|
62
|
+
program.command("validate").description("Validate translations").action(validateAction);
|
|
63
|
+
program.parseAsync();
|
|
110
64
|
|
|
111
65
|
//#endregion
|
|
112
66
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Command","Option"],"sources":["../src/getGitBranch.ts","../package.json","../src/index.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\n\n// Modified from `env-ci` to use `execSync`\n// https://github.com/semantic-release/env-ci/blob/e11b2965aa82cd7366511635d9bc4ae3d0144f64/lib/git.js#L11C24-L35\nexport function getGitBranch() {\n try {\n const headRef = execSync('git rev-parse --abbrev-ref HEAD', {\n encoding: 'utf8',\n }).trim();\n\n if (headRef === 'HEAD') {\n const branch = execSync('git show -s --pretty=%d HEAD', {\n encoding: 'utf8',\n })\n .trim()\n .replace(/^\\(|\\)$/g, '')\n .split(', ')\n .find((b) => b.startsWith('origin/'));\n\n return branch ? branch.match(/^origin\\/(?<branch>.+)/)?.[1] : undefined;\n }\n\n return headRef;\n } catch {\n return undefined;\n }\n}\n","","/* eslint-disable no-console */\nimport { pull, push } from '@vocab/phrase';\nimport { type UserConfig, resolveConfig, compile, validate } from '@vocab/core';\nimport { getGitBranch } from './getGitBranch.js';\nimport { Command, Option } from 'commander';\nimport {\n description,\n version,\n} from '@vocab/cli/package.json' with { type: 'json' };\n\nconst branch = getGitBranch();\nconst DEFAULT_BRANCH = branch || 'local-development';\n\nconst program = new Command();\n\nprogram\n .name('vocab')\n .version(version)\n .description(description)\n .option('--config <path>', 'Path to config file')\n .hook('preAction', async (thisCommand, actionCommand) => {\n const options = thisCommand.optsWithGlobals<{ config?: string }>();\n\n console.log('Loading configuration from', options.config || process.cwd());\n const userConfig = await resolveConfig(options.config);\n\n if (!userConfig) {\n throw new Error('No configuration file found');\n }\n\n console.log('Successfully loaded configuration');\n actionCommand.setOptionValue('userConfig', userConfig);\n });\n\nconst branchOption = new Option(\n '--branch',\n 'The Phrase branch to target',\n).default(DEFAULT_BRANCH);\n\nconst pushAction = async (options: {\n branch: string;\n deleteUnusedKeys?: boolean;\n ignore?: string[];\n userConfig: UserConfig;\n}) => {\n await push(\n {\n branch: options.branch,\n deleteUnusedKeys: options.deleteUnusedKeys,\n ignore: options.ignore,\n },\n options.userConfig,\n );\n};\n\nprogram\n .command('push')\n .description('Push translations to Phrase')\n .addOption(branchOption)\n .option(\n '--delete-unused-keys',\n 'Whether or not to delete unused keys after pushing',\n false,\n )\n .option(\n '--ignore <paths...>',\n 'Array of glob paths to ignore when searching for keys to push',\n [],\n )\n .action(pushAction);\n\nconst pullAction = async (options: {\n branch: string;\n errorOnNoGlobalKeyTranslation: boolean;\n userConfig: UserConfig;\n}) => {\n await pull(\n {\n branch: options.branch,\n errorOnNoGlobalKeyTranslation:\n options.errorOnNoGlobalKeyTranslation || false,\n },\n options.userConfig,\n );\n};\n\nprogram\n .command('pull')\n .description('Pull translations from Phrase')\n .addOption(branchOption)\n .option(\n '--error-on-no-global-key-translation',\n 'Throw an error when there is no translation for a global key',\n false,\n )\n .action(pullAction);\n\nconst compileAction = async (options: {\n watch: boolean;\n userConfig: UserConfig;\n}) => {\n await compile({ watch: options.watch }, options.userConfig);\n};\n\nprogram\n .command('compile')\n .description('Compile translations')\n .option('--watch', 'Watch for changes', false)\n .action(compileAction);\n\nconst validateAction = async (options: { userConfig: UserConfig }) => {\n console.log('Validating project');\n const valid = await validate(options.userConfig);\n\n if (!valid) {\n throw new Error('Project is invalid');\n }\n\n console.log('Project is valid');\n};\n\nprogram\n .command('validate')\n .description('Validate translations')\n .action(validateAction);\n\nprogram.parseAsync();\n"],"mappings":";;;;;;AAIA,SAAgB,eAAe;AAC7B,KAAI;EACF,MAAM,2CAAmB,mCAAmC,EAC1D,UAAU,QACX,CAAC,CAAC,MAAM;AAET,MAAI,YAAY,QAAQ;GACtB,MAAM,0CAAkB,gCAAgC,EACtD,UAAU,QACX,CAAC,CACC,MAAM,CACN,QAAQ,YAAY,GAAG,CACvB,MAAM,KAAK,CACX,MAAM,MAAM,EAAE,WAAW,UAAU,CAAC;AAEvC,UAAO,SAAS,OAAO,MAAM,yBAAyB,GAAG,KAAK;;AAGhE,SAAO;SACD;AACN;;;;;;;;;;;AEbJ,MAAM,iBADS,cAAc,IACI;AAEjC,MAAM,UAAU,IAAIA,mBAAS;AAE7B,QACG,KAAK,QAAQ,CACb,QAAQ,QAAQ,CAChB,YAAY,YAAY,CACxB,OAAO,mBAAmB,sBAAsB,CAChD,KAAK,aAAa,OAAO,aAAa,kBAAkB;CACvD,MAAM,UAAU,YAAY,iBAAsC;AAElE,SAAQ,IAAI,8BAA8B,QAAQ,UAAU,QAAQ,KAAK,CAAC;CAC1E,MAAM,aAAa,qCAAoB,QAAQ,OAAO;AAEtD,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,8BAA8B;AAGhD,SAAQ,IAAI,oCAAoC;AAChD,eAAc,eAAe,cAAc,WAAW;EACtD;AAEJ,MAAM,eAAe,IAAIC,iBACvB,YACA,8BACD,CAAC,QAAQ,eAAe;AAEzB,MAAM,aAAa,OAAO,YAKpB;AACJ,+BACE;EACE,QAAQ,QAAQ;EAChB,kBAAkB,QAAQ;EAC1B,QAAQ,QAAQ;EACjB,EACD,QAAQ,WACT;;AAGH,QACG,QAAQ,OAAO,CACf,YAAY,8BAA8B,CAC1C,UAAU,aAAa,CACvB,OACC,wBACA,sDACA,MACD,CACA,OACC,uBACA,iEACA,EAAE,CACH,CACA,OAAO,WAAW;AAErB,MAAM,aAAa,OAAO,YAIpB;AACJ,+BACE;EACE,QAAQ,QAAQ;EAChB,+BACE,QAAQ,iCAAiC;EAC5C,EACD,QAAQ,WACT;;AAGH,QACG,QAAQ,OAAO,CACf,YAAY,gCAAgC,CAC5C,UAAU,aAAa,CACvB,OACC,wCACA,gEACA,MACD,CACA,OAAO,WAAW;AAErB,MAAM,gBAAgB,OAAO,YAGvB;AACJ,gCAAc,EAAE,OAAO,QAAQ,OAAO,EAAE,QAAQ,WAAW;;AAG7D,QACG,QAAQ,UAAU,CAClB,YAAY,uBAAuB,CACnC,OAAO,WAAW,qBAAqB,MAAM,CAC7C,OAAO,cAAc;AAExB,MAAM,iBAAiB,OAAO,YAAwC;AACpE,SAAQ,IAAI,qBAAqB;AAGjC,KAAI,CAFU,gCAAe,QAAQ,WAAW,CAG9C,OAAM,IAAI,MAAM,qBAAqB;AAGvC,SAAQ,IAAI,mBAAmB;;AAGjC,QACG,QAAQ,WAAW,CACnB,YAAY,wBAAwB,CACpC,OAAO,eAAe;AAEzB,QAAQ,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocab/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
|
+
"description": "A CLI for generating typed Vocab translations and interacting with 3rd-party localization services",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/seek-oss/vocab.git",
|
|
@@ -22,12 +23,11 @@
|
|
|
22
23
|
"author": "SEEK",
|
|
23
24
|
"license": "MIT",
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
+
"commander": "^14.0.2",
|
|
26
27
|
"@vocab/core": "^1.7.6",
|
|
27
28
|
"@vocab/phrase": "^2.1.10"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^22.0.0"
|
|
31
|
-
"@types/yargs": "^17.0.32"
|
|
31
|
+
"@types/node": "^22.0.0"
|
|
32
32
|
}
|
|
33
33
|
}
|