@plasmicapp/cli 0.1.290 → 0.1.292
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/actions/localization-strings.d.ts +2 -1
- package/dist/actions/localization-strings.js +6 -2
- package/dist/api.d.ts +1 -1
- package/dist/api.js +2 -2
- package/dist/index.js +6 -2
- package/dist/plasmic.schema.json +4 -0
- package/dist/utils/config-utils.d.ts +8 -0
- package/package.json +2 -3
- package/src/actions/localization-strings.ts +7 -1
- package/src/api.ts +3 -2
- package/src/index.ts +7 -2
- package/src/utils/config-utils.ts +8 -0
|
@@ -6,6 +6,7 @@ export interface LocalizationStringsArgs extends CommonArgs {
|
|
|
6
6
|
format: "po" | "json" | "lingui";
|
|
7
7
|
output: string;
|
|
8
8
|
forceOverwrite: boolean;
|
|
9
|
-
keyScheme: "content" | "hash" | undefined;
|
|
9
|
+
keyScheme: "content" | "hash" | "path" | undefined;
|
|
10
|
+
tagPrefix: string | undefined;
|
|
10
11
|
}
|
|
11
12
|
export declare function localizationStrings(opts: LocalizationStringsArgs): Promise<void>;
|
|
@@ -24,7 +24,7 @@ const file_utils_1 = require("../utils/file-utils");
|
|
|
24
24
|
const get_context_1 = require("../utils/get-context");
|
|
25
25
|
const user_utils_1 = require("../utils/user-utils");
|
|
26
26
|
function localizationStrings(opts) {
|
|
27
|
-
var _a, _b;
|
|
27
|
+
var _a, _b, _c;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
if (!opts.projects || opts.projects.length === 0) {
|
|
30
30
|
throw new lib_1.HandledError(`Missing projects.`);
|
|
@@ -47,6 +47,7 @@ function localizationStrings(opts) {
|
|
|
47
47
|
: "data.json"
|
|
48
48
|
: opts.output;
|
|
49
49
|
let keyScheme = opts.keyScheme;
|
|
50
|
+
let tagPrefix = opts.tagPrefix;
|
|
50
51
|
const projectTokensFromConfig = [];
|
|
51
52
|
const auth = yield auth_utils_1.getCurrentAuth(opts.auth);
|
|
52
53
|
const maybeConfigFile = opts.config || config_utils_1.findConfigFile(opts.baseDir, { traverseParents: true });
|
|
@@ -58,6 +59,9 @@ function localizationStrings(opts) {
|
|
|
58
59
|
if (!keyScheme) {
|
|
59
60
|
keyScheme = (_b = context.config.i18n) === null || _b === void 0 ? void 0 : _b.keyScheme;
|
|
60
61
|
}
|
|
62
|
+
if (!tagPrefix) {
|
|
63
|
+
tagPrefix = (_c = context.config.i18n) === null || _c === void 0 ? void 0 : _c.tagPrefix;
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
const projectIdsAndTokens = [
|
|
63
67
|
...parsedProjectTokens,
|
|
@@ -70,7 +74,7 @@ function localizationStrings(opts) {
|
|
|
70
74
|
token: "",
|
|
71
75
|
});
|
|
72
76
|
deps_1.logger.info(`Generating localization strings for ${chalk_1.default.bold(opts.projects.join(", "))}...`);
|
|
73
|
-
const data = yield api.genLocalizationStrings(opts.projects, opts.format, keyScheme !== null && keyScheme !== void 0 ? keyScheme : "content", projectIdsAndTokens);
|
|
77
|
+
const data = yield api.genLocalizationStrings(opts.projects, opts.format, keyScheme !== null && keyScheme !== void 0 ? keyScheme : "content", tagPrefix, projectIdsAndTokens);
|
|
74
78
|
if (file_utils_1.existsBuffered(output)) {
|
|
75
79
|
const overwrite = yield user_utils_1.confirmWithUser(`File ${output} already exists. Do you want to overwrite?`, opts.forceOverwrite);
|
|
76
80
|
if (!overwrite) {
|
package/dist/api.d.ts
CHANGED
|
@@ -200,7 +200,7 @@ export declare class PlasmicApi {
|
|
|
200
200
|
metadata?: Metadata;
|
|
201
201
|
}): Promise<ProjectBundle>;
|
|
202
202
|
projectMeta(projectId: string): Promise<ProjectMetaInfo>;
|
|
203
|
-
genLocalizationStrings(projects: readonly string[], format: "po" | "json" | "lingui", keyScheme: "content" | "hash", projectIdsAndTokens: ProjectIdAndToken[]): Promise<string>;
|
|
203
|
+
genLocalizationStrings(projects: readonly string[], format: "po" | "json" | "lingui", keyScheme: "content" | "hash" | "path", tagPrefix: string | undefined, projectIdsAndTokens: ProjectIdAndToken[]): Promise<string>;
|
|
204
204
|
uploadBundle(projectId: string, bundleName: string, bundleJs: string, css: string[], metaJson: string, genModulePath: string | undefined, genCssPaths: string[], pkgVersion: string | undefined, extraPropMetaJson: string | undefined, themeProviderWrapper: string | undefined, themeModule: string | undefined): Promise<StyleTokensMap>;
|
|
205
205
|
projectStyleTokens(projectId: string, branchName: string, versionRange?: string): Promise<StyleTokensMap>;
|
|
206
206
|
projectIcons(projectId: string, branchName: string, versionRange?: string, iconIds?: string[]): Promise<ProjectIconsResponse>;
|
package/dist/api.js
CHANGED
|
@@ -99,9 +99,9 @@ class PlasmicApi {
|
|
|
99
99
|
return result.data;
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
genLocalizationStrings(projects, format, keyScheme, projectIdsAndTokens) {
|
|
102
|
+
genLocalizationStrings(projects, format, keyScheme, tagPrefix, projectIdsAndTokens) {
|
|
103
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const result = yield this.get(`${this.codegenHost}/api/v1/localization/gen-texts?format=${format}&keyScheme=${keyScheme}&preview=true&${projects
|
|
104
|
+
const result = yield this.get(`${this.codegenHost}/api/v1/localization/gen-texts?format=${format}&keyScheme=${keyScheme}&tagPrefix=${tagPrefix}&preview=true&${projects
|
|
105
105
|
.map((p) => `projectId=${p}`)
|
|
106
106
|
.join("&")}`, undefined, {
|
|
107
107
|
"x-plasmic-api-project-tokens": projectIdsAndTokens
|
package/dist/index.js
CHANGED
|
@@ -205,9 +205,13 @@ yargs_1.default
|
|
|
205
205
|
default: "json",
|
|
206
206
|
})
|
|
207
207
|
.option("key-scheme", {
|
|
208
|
-
describe: "What value to use as message keys;
|
|
208
|
+
describe: "What value to use as message keys; `content` uses the message content itself, `hash` uses a hash of the content, and `path` uses a a hierarchical string containing the project id, component name, element name, and related variants, and does not encode the text content in the key. Defaults to whatever is specified in plasmic.json, or `content`",
|
|
209
|
+
type: "string",
|
|
210
|
+
choices: ["content", "hash", "path"],
|
|
211
|
+
})
|
|
212
|
+
.option("tag-prefix", {
|
|
213
|
+
describe: "By default, rich text with markup tags look like '<0>hello</0>'. If your localization framework requires num-numeric tags, then specify a prefix; for example a prefix of 'n' turns it into '<n0>hello</n0>'.",
|
|
209
214
|
type: "string",
|
|
210
|
-
choices: ["content", "hash"],
|
|
211
215
|
})
|
|
212
216
|
.option("output", {
|
|
213
217
|
alias: "o",
|
package/dist/plasmic.schema.json
CHANGED
|
@@ -188,6 +188,10 @@
|
|
|
188
188
|
"hash"
|
|
189
189
|
],
|
|
190
190
|
"type": "string"
|
|
191
|
+
},
|
|
192
|
+
"tagPrefix": {
|
|
193
|
+
"description": "For localization, rich text with embedded tags are exported as\n\"Hello <0>there</0>, I am <1>here</1>\". Some frameworks, like\nreact-intl, doesn't work with numbers as tag names, so you can\nspecify a prefix. For example, a tagPrefix of \"n\" turns the above\ninto \"Hello <n0>there</n0>, I am <n1>here</n1>\".",
|
|
194
|
+
"type": "string"
|
|
191
195
|
}
|
|
192
196
|
},
|
|
193
197
|
"required": [
|
|
@@ -254,6 +254,14 @@ export interface I18NConfig {
|
|
|
254
254
|
* or by a hash of its content
|
|
255
255
|
*/
|
|
256
256
|
keyScheme: "content" | "hash";
|
|
257
|
+
/**
|
|
258
|
+
* For localization, rich text with embedded tags are exported as
|
|
259
|
+
* "Hello <0>there</0>, I am <1>here</1>". Some frameworks, like
|
|
260
|
+
* react-intl, doesn't work with numbers as tag names, so you can
|
|
261
|
+
* specify a prefix. For example, a tagPrefix of "n" turns the above
|
|
262
|
+
* into "Hello <n0>there</n0>, I am <n1>here</n1>".
|
|
263
|
+
*/
|
|
264
|
+
tagPrefix?: string;
|
|
257
265
|
}
|
|
258
266
|
export interface PlasmicLock {
|
|
259
267
|
projects: ProjectLock[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.292",
|
|
4
4
|
"description": "plasmic cli for syncing local code with Plasmic designs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12"
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/preset-typescript": "^7.12.1",
|
|
23
|
-
"@plasmicapp/react-web": "0.2.223",
|
|
24
23
|
"@types/cli-progress": "^3.11.0",
|
|
25
24
|
"@types/findup-sync": "^2.0.2",
|
|
26
25
|
"@types/glob": "^7.1.3",
|
|
@@ -81,5 +80,5 @@
|
|
|
81
80
|
"wrap-ansi": "^7.0.0",
|
|
82
81
|
"yargs": "^15.4.1"
|
|
83
82
|
},
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "b416c3aff370f8f8b0c884e3700bd8fe61ad3e2b"
|
|
85
84
|
}
|
|
@@ -17,7 +17,8 @@ export interface LocalizationStringsArgs extends CommonArgs {
|
|
|
17
17
|
format: "po" | "json" | "lingui";
|
|
18
18
|
output: string;
|
|
19
19
|
forceOverwrite: boolean;
|
|
20
|
-
keyScheme: "content" | "hash" | undefined;
|
|
20
|
+
keyScheme: "content" | "hash" | "path" | undefined;
|
|
21
|
+
tagPrefix: string | undefined;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export async function localizationStrings(
|
|
@@ -47,6 +48,7 @@ export async function localizationStrings(
|
|
|
47
48
|
: "data.json"
|
|
48
49
|
: opts.output;
|
|
49
50
|
let keyScheme = opts.keyScheme;
|
|
51
|
+
let tagPrefix = opts.tagPrefix;
|
|
50
52
|
const projectTokensFromConfig: ProjectIdAndToken[] = [];
|
|
51
53
|
const auth = await getCurrentAuth(opts.auth);
|
|
52
54
|
const maybeConfigFile =
|
|
@@ -59,6 +61,9 @@ export async function localizationStrings(
|
|
|
59
61
|
if (!keyScheme) {
|
|
60
62
|
keyScheme = context.config.i18n?.keyScheme;
|
|
61
63
|
}
|
|
64
|
+
if (!tagPrefix) {
|
|
65
|
+
tagPrefix = context.config.i18n?.tagPrefix;
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
const projectIdsAndTokens = [
|
|
@@ -83,6 +88,7 @@ export async function localizationStrings(
|
|
|
83
88
|
opts.projects,
|
|
84
89
|
opts.format,
|
|
85
90
|
keyScheme ?? "content",
|
|
91
|
+
tagPrefix,
|
|
86
92
|
projectIdsAndTokens
|
|
87
93
|
);
|
|
88
94
|
if (existsBuffered(output)) {
|
package/src/api.ts
CHANGED
|
@@ -302,13 +302,14 @@ export class PlasmicApi {
|
|
|
302
302
|
async genLocalizationStrings(
|
|
303
303
|
projects: readonly string[],
|
|
304
304
|
format: "po" | "json" | "lingui",
|
|
305
|
-
keyScheme: "content" | "hash",
|
|
305
|
+
keyScheme: "content" | "hash" | "path",
|
|
306
|
+
tagPrefix: string | undefined,
|
|
306
307
|
projectIdsAndTokens: ProjectIdAndToken[]
|
|
307
308
|
) {
|
|
308
309
|
const result = await this.get(
|
|
309
310
|
`${
|
|
310
311
|
this.codegenHost
|
|
311
|
-
}/api/v1/localization/gen-texts?format=${format}&keyScheme=${keyScheme}&preview=true&${projects
|
|
312
|
+
}/api/v1/localization/gen-texts?format=${format}&keyScheme=${keyScheme}&tagPrefix=${tagPrefix}&preview=true&${projects
|
|
312
313
|
.map((p) => `projectId=${p}`)
|
|
313
314
|
.join("&")}`,
|
|
314
315
|
undefined,
|
package/src/index.ts
CHANGED
|
@@ -254,9 +254,14 @@ yargs
|
|
|
254
254
|
})
|
|
255
255
|
.option("key-scheme", {
|
|
256
256
|
describe:
|
|
257
|
-
"What value to use as message keys;
|
|
257
|
+
"What value to use as message keys; `content` uses the message content itself, `hash` uses a hash of the content, and `path` uses a a hierarchical string containing the project id, component name, element name, and related variants, and does not encode the text content in the key. Defaults to whatever is specified in plasmic.json, or `content`",
|
|
258
|
+
type: "string",
|
|
259
|
+
choices: ["content", "hash", "path"],
|
|
260
|
+
})
|
|
261
|
+
.option("tag-prefix", {
|
|
262
|
+
describe:
|
|
263
|
+
"By default, rich text with markup tags look like '<0>hello</0>'. If your localization framework requires num-numeric tags, then specify a prefix; for example a prefix of 'n' turns it into '<n0>hello</n0>'.",
|
|
258
264
|
type: "string",
|
|
259
|
-
choices: ["content", "hash"],
|
|
260
265
|
})
|
|
261
266
|
.option("output", {
|
|
262
267
|
alias: "o",
|
|
@@ -355,6 +355,14 @@ export interface I18NConfig {
|
|
|
355
355
|
* or by a hash of its content
|
|
356
356
|
*/
|
|
357
357
|
keyScheme: "content" | "hash";
|
|
358
|
+
/**
|
|
359
|
+
* For localization, rich text with embedded tags are exported as
|
|
360
|
+
* "Hello <0>there</0>, I am <1>here</1>". Some frameworks, like
|
|
361
|
+
* react-intl, doesn't work with numbers as tag names, so you can
|
|
362
|
+
* specify a prefix. For example, a tagPrefix of "n" turns the above
|
|
363
|
+
* into "Hello <n0>there</n0>, I am <n1>here</n1>".
|
|
364
|
+
*/
|
|
365
|
+
tagPrefix?: string;
|
|
358
366
|
}
|
|
359
367
|
|
|
360
368
|
export interface PlasmicLock {
|