@plasmicapp/cli 0.1.293 → 0.1.295

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.
Files changed (55) hide show
  1. package/dist/__mocks__/api.js +10 -6
  2. package/dist/__tests__/code-utils-spec.js +12 -12
  3. package/dist/__tests__/file-utils.spec.js +11 -11
  4. package/dist/__tests__/ftue-spec.js +7 -7
  5. package/dist/__tests__/project-api-token-spec.js +33 -33
  6. package/dist/__tests__/versioned-sync-spec.js +20 -20
  7. package/dist/actions/auth.d.ts +1 -1
  8. package/dist/actions/auth.js +3 -3
  9. package/dist/actions/fix-imports.js +3 -3
  10. package/dist/actions/info.js +1 -1
  11. package/dist/actions/init.js +28 -28
  12. package/dist/actions/localization-strings.js +34 -26
  13. package/dist/actions/project-token.d.ts +1 -1
  14. package/dist/actions/project-token.js +6 -4
  15. package/dist/actions/sync-components.js +29 -29
  16. package/dist/actions/sync-global-contexts.js +5 -5
  17. package/dist/actions/sync-global-variants.js +9 -9
  18. package/dist/actions/sync-icons.js +10 -10
  19. package/dist/actions/sync-images.js +20 -20
  20. package/dist/actions/sync-styles.js +4 -4
  21. package/dist/actions/sync.js +52 -48
  22. package/dist/actions/upload-bundle.js +4 -4
  23. package/dist/actions/watch.js +10 -6
  24. package/dist/api.d.ts +1 -1
  25. package/dist/api.js +1 -1
  26. package/dist/deps.js +2 -0
  27. package/dist/index.js +28 -24
  28. package/dist/lib.js +1 -0
  29. package/dist/migrations/0.1.28-tsToTsx.js +3 -3
  30. package/dist/migrations/migrations.d.ts +2 -2
  31. package/dist/migrations/migrations.js +12 -12
  32. package/dist/plasmic.schema.json +3 -2
  33. package/dist/utils/auth-utils.d.ts +2 -2
  34. package/dist/utils/auth-utils.js +8 -8
  35. package/dist/utils/checksum.js +2 -2
  36. package/dist/utils/code-utils.js +40 -32
  37. package/dist/utils/config-utils.d.ts +3 -3
  38. package/dist/utils/config-utils.js +5 -5
  39. package/dist/utils/envdetect.js +8 -8
  40. package/dist/utils/error.js +3 -2
  41. package/dist/utils/file-utils.js +3 -3
  42. package/dist/utils/get-context.js +20 -16
  43. package/dist/utils/help.js +2 -2
  44. package/dist/utils/lang-utils.d.ts +1 -1
  45. package/dist/utils/lang-utils.js +2 -1
  46. package/dist/utils/npm-utils.js +18 -16
  47. package/dist/utils/resolve-utils.js +11 -7
  48. package/dist/utils/semver.d.ts +2 -2
  49. package/dist/utils/semver.js +64 -35
  50. package/dist/utils/test-utils.js +9 -5
  51. package/package.json +5 -5
  52. package/src/actions/init.ts +2 -2
  53. package/src/actions/localization-strings.ts +34 -21
  54. package/src/index.ts +1 -1
  55. package/src/utils/config-utils.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.293",
3
+ "version": "0.1.295",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -36,8 +36,8 @@
36
36
  "@types/uuid": "^8.3.0",
37
37
  "@types/wrap-ansi": "^3.0.0",
38
38
  "@types/yargs": "^15.0.5",
39
- "@typescript-eslint/eslint-plugin": "^3.8.0",
40
- "@typescript-eslint/parser": "^3.8.0",
39
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
40
+ "@typescript-eslint/parser": "^5.61.0",
41
41
  "eslint": "^7.7.0",
42
42
  "jest": "^26.1.0",
43
43
  "jest-circus": "^26.1.0",
@@ -71,7 +71,7 @@
71
71
  "prettier": "^2.0.5",
72
72
  "semver": "^7.3.2",
73
73
  "socket.io-client": "^4.1.2",
74
- "typescript": "^3.9.6",
74
+ "typescript": "^4.9.5",
75
75
  "upath": "^1.2.0",
76
76
  "update-notifier": "^4.1.0",
77
77
  "utility-types": "^3.10.0",
@@ -80,5 +80,5 @@
80
80
  "wrap-ansi": "^7.0.0",
81
81
  "yargs": "^15.4.1"
82
82
  },
83
- "gitHead": "44f8c8ab413dee1f09112df30df9bdf323ac5214"
83
+ "gitHead": "d6193c35e278eaf8149c584a38c6ac9cd8f38dee"
84
84
  }
@@ -286,7 +286,7 @@ async function deriveInitAnswers(
286
286
  simulatePrompt(useExpressQuestion, "yes", true);
287
287
  return answers;
288
288
  } else {
289
- const useExpress = await inquirer.prompt([useExpressQuestion]);
289
+ const useExpress: any = await inquirer.prompt([useExpressQuestion]);
290
290
  if (useExpress.continue === "yes") {
291
291
  return answers;
292
292
  }
@@ -312,7 +312,7 @@ async function deriveInitAnswers(
312
312
  default: answers[name],
313
313
  });
314
314
  // Not sure why TS complains here without this cast.
315
- (answers as any)[name] = ans[name];
315
+ (answers as any)[name] = (ans as any)[name];
316
316
  }
317
317
  // Other questions are silently skipped
318
318
  }
@@ -25,10 +25,40 @@ export interface LocalizationStringsArgs extends CommonArgs {
25
25
  export async function localizationStrings(
26
26
  opts: LocalizationStringsArgs
27
27
  ): Promise<void> {
28
- if (!opts.projects || opts.projects.length === 0) {
28
+ if (!opts.baseDir) {
29
+ opts.baseDir = process.cwd();
30
+ }
31
+
32
+ const maybeConfigFile =
33
+ opts.config || findConfigFile(opts.baseDir, { traverseParents: true });
34
+
35
+ let projectSpecs = opts.projects;
36
+ let keyScheme = opts.keyScheme;
37
+ let tagPrefix = opts.tagPrefix;
38
+ const projectTokensFromConfig: ProjectIdAndToken[] = [];
39
+ if (maybeConfigFile) {
40
+ // if plasmic.json exists, then we can derive some settings from
41
+ // there instead.
42
+ logger.info(`Using settings from ${maybeConfigFile}...`);
43
+ const context = await getContext(opts, { enableSkipAuth: true });
44
+ context.config.projects.forEach((p) => {
45
+ projectTokensFromConfig.push(pick(p, "projectId", "projectApiToken"));
46
+ });
47
+ if (!projectSpecs || projectSpecs.length === 0) {
48
+ projectSpecs = context.config.projects.map(
49
+ (p) => p.projectId + (p.version === "latest" ? "" : `@${p.version}`)
50
+ );
51
+ }
52
+ if (!keyScheme) {
53
+ keyScheme = context.config.i18n?.keyScheme;
54
+ }
55
+ if (!tagPrefix) {
56
+ tagPrefix = context.config.i18n?.tagPrefix;
57
+ }
58
+ }
59
+ if (!projectSpecs || projectSpecs.length === 0) {
29
60
  throw new HandledError(`Missing projects.`);
30
61
  }
31
- if (!opts.baseDir) opts.baseDir = process.cwd();
32
62
  const parsedProjectTokens: ProjectIdAndToken[] = (
33
63
  opts.projectTokens ?? []
34
64
  ).map((val) => {
@@ -48,24 +78,7 @@ export async function localizationStrings(
48
78
  ? "data.po"
49
79
  : "data.json"
50
80
  : opts.output;
51
- let keyScheme = opts.keyScheme;
52
- let tagPrefix = opts.tagPrefix;
53
- const projectTokensFromConfig: ProjectIdAndToken[] = [];
54
81
  const auth = await getCurrentAuth(opts.auth);
55
- const maybeConfigFile =
56
- opts.config || findConfigFile(opts.baseDir, { traverseParents: true });
57
- if (maybeConfigFile) {
58
- const context = await getContext(opts, { enableSkipAuth: true });
59
- context.config.projects.forEach((p) => {
60
- projectTokensFromConfig.push(pick(p, "projectId", "projectApiToken"));
61
- });
62
- if (!keyScheme) {
63
- keyScheme = context.config.i18n?.keyScheme;
64
- }
65
- if (!tagPrefix) {
66
- tagPrefix = context.config.i18n?.tagPrefix;
67
- }
68
- }
69
82
 
70
83
  const projectIdsAndTokens = [
71
84
  ...parsedProjectTokens,
@@ -82,11 +95,11 @@ export async function localizationStrings(
82
95
  );
83
96
  logger.info(
84
97
  `Generating localization strings for ${chalk.bold(
85
- opts.projects.join(", ")
98
+ projectSpecs.join(", ")
86
99
  )}...`
87
100
  );
88
101
  const data = await api.genLocalizationStrings(
89
- opts.projects,
102
+ projectSpecs,
90
103
  opts.format,
91
104
  keyScheme ?? "content",
92
105
  tagPrefix,
package/src/index.ts CHANGED
@@ -238,7 +238,7 @@ yargs
238
238
  .option("projects", {
239
239
  alias: "p",
240
240
  describe:
241
- "One or more projects to generate localization strings, separated by comma. Version constraints can be specified using @. Example: projectid, projectid@>=version",
241
+ "One or more projects to generate localization strings, separated by comma. Version constraints can be specified using @. Example: projectid, projectid@>=version. If not specified, will be derived from plasmic.json if you are using codegen.",
242
242
  type: "array",
243
243
  })
244
244
  .option("host", {
@@ -351,10 +351,10 @@ export interface ProjectLock {
351
351
 
352
352
  export interface I18NConfig {
353
353
  /**
354
- * For localization, whether the extracted strings are keyed by its content
355
- * or by a hash of its content
354
+ * For localization, whether the extracted strings are keyed by its content,
355
+ * or by a hash of its content, or by where the string is found ("path")
356
356
  */
357
- keyScheme: "content" | "hash";
357
+ keyScheme: "content" | "hash" | "path";
358
358
  /**
359
359
  * For localization, rich text with embedded tags are exported as
360
360
  * "Hello <0>there</0>, I am <1>here</1>". Some frameworks, like