@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
@@ -29,9 +29,9 @@ function initPlasmic(opts) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
30
  if (!opts.baseDir)
31
31
  opts.baseDir = process.cwd();
32
- yield auth_utils_1.getOrStartAuth(opts);
33
- const configFile = opts.config || config_utils_1.findConfigFile(opts.baseDir, { traverseParents: false });
34
- if (configFile && file_utils_1.existsBuffered(configFile)) {
32
+ yield (0, auth_utils_1.getOrStartAuth)(opts);
33
+ const configFile = opts.config || (0, config_utils_1.findConfigFile)(opts.baseDir, { traverseParents: false });
34
+ if (configFile && (0, file_utils_1.existsBuffered)(configFile)) {
35
35
  deps_1.logger.error("You already have a plasmic.json file! Please either delete or edit it directly.");
36
36
  return;
37
37
  }
@@ -39,19 +39,19 @@ function initPlasmic(opts) {
39
39
  const newConfigFile = opts.config || upath_1.default.join(opts.baseDir, config_utils_1.CONFIG_FILE_NAME);
40
40
  const answers = yield deriveInitAnswers(opts);
41
41
  const initConfig = createInitConfig(answers);
42
- yield config_utils_1.writeConfig(newConfigFile, initConfig, opts.baseDir);
42
+ yield (0, config_utils_1.writeConfig)(newConfigFile, initConfig, opts.baseDir);
43
43
  if (!process.env.QUIET) {
44
44
  deps_1.logger.info("Successfully created plasmic.json.\n");
45
45
  }
46
- const answer = yield user_utils_1.confirmWithUser("@plasmicapp/react-web is a small runtime required by Plasmic-generated code.\n Do you want to add them now?", opts.yes);
46
+ const answer = yield (0, user_utils_1.confirmWithUser)("@plasmicapp/react-web is a small runtime required by Plasmic-generated code.\n Do you want to add them now?", opts.yes);
47
47
  if (answer) {
48
- npm_utils_1.installUpgrade(initConfig, "@plasmicapp/react-web", opts.baseDir);
48
+ (0, npm_utils_1.installUpgrade)(initConfig, "@plasmicapp/react-web", opts.baseDir);
49
49
  }
50
50
  });
51
51
  }
52
52
  exports.initPlasmic = initPlasmic;
53
53
  function createInitConfig(opts) {
54
- return config_utils_1.fillDefaults(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ srcDir: opts.srcDir, defaultPlasmicDir: opts.plasmicDir }, (opts.platform === "nextjs" && {
54
+ return (0, config_utils_1.fillDefaults)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ srcDir: opts.srcDir, defaultPlasmicDir: opts.plasmicDir }, (opts.platform === "nextjs" && {
55
55
  nextjsConfig: {
56
56
  pagesDir: opts.pagesDir,
57
57
  },
@@ -59,7 +59,7 @@ function createInitConfig(opts) {
59
59
  gatsbyConfig: {
60
60
  pagesDir: opts.pagesDir,
61
61
  },
62
- })), { code: Object.assign(Object.assign(Object.assign({}, (opts.codeLang && { lang: opts.codeLang })), (opts.codeScheme && { scheme: opts.codeScheme })), (opts.reactRuntime && { reactRuntime: opts.reactRuntime })), style: Object.assign({}, (opts.styleScheme && { scheme: opts.styleScheme })), images: Object.assign(Object.assign(Object.assign({}, (opts.imagesScheme && { scheme: opts.imagesScheme })), (opts.imagesScheme && { publicDir: opts.imagesPublicDir })), (opts.imagesScheme && { publicUrlPrefix: opts.imagesPublicUrlPrefix })) }), (opts.platform && { platform: opts.platform })), { cliVersion: npm_utils_1.getCliVersion() }));
62
+ })), { code: Object.assign(Object.assign(Object.assign({}, (opts.codeLang && { lang: opts.codeLang })), (opts.codeScheme && { scheme: opts.codeScheme })), (opts.reactRuntime && { reactRuntime: opts.reactRuntime })), style: Object.assign({}, (opts.styleScheme && { scheme: opts.styleScheme })), images: Object.assign(Object.assign(Object.assign({}, (opts.imagesScheme && { scheme: opts.imagesScheme })), (opts.imagesScheme && { publicDir: opts.imagesPublicDir })), (opts.imagesScheme && { publicUrlPrefix: opts.imagesPublicUrlPrefix })) }), (opts.platform && { platform: opts.platform })), { cliVersion: (0, npm_utils_1.getCliVersion)() }));
63
63
  }
64
64
  /**
65
65
  * Pretty-print the question along with the default answer, as if that was the choice
@@ -78,19 +78,19 @@ function deriveInitAnswers(opts) {
78
78
  const plasmicRootDir = opts.config ? upath_1.default.dirname(opts.config) : opts.baseDir;
79
79
  const platform = !!opts.platform
80
80
  ? opts.platform
81
- : envdetect_1.detectNextJs()
81
+ : (0, envdetect_1.detectNextJs)()
82
82
  ? "nextjs"
83
- : envdetect_1.detectGatsby()
83
+ : (0, envdetect_1.detectGatsby)()
84
84
  ? "gatsby"
85
- : envdetect_1.detectCreateReactApp()
85
+ : (0, envdetect_1.detectCreateReactApp)()
86
86
  ? "react"
87
87
  : "";
88
88
  const isCra = platform === "react";
89
89
  const isNext = platform === "nextjs";
90
- const isNextAppDir = isNext && envdetect_1.detectNextJsAppDir();
90
+ const isNextAppDir = isNext && (0, envdetect_1.detectNextJsAppDir)();
91
91
  const isGatsby = platform === "gatsby";
92
92
  const isGeneric = !isCra && !isNext && !isGatsby;
93
- const isTypescript = envdetect_1.detectTypescript();
93
+ const isTypescript = (0, envdetect_1.detectTypescript)();
94
94
  if (isNext) {
95
95
  if (isNextAppDir) {
96
96
  deps_1.logger.info("Detected Next.js with app/ directory (experimental)...");
@@ -113,7 +113,7 @@ function deriveInitAnswers(opts) {
113
113
  : isCra
114
114
  ? getCraDefaults(plasmicRootDir)
115
115
  : getGenericDefaults(plasmicRootDir);
116
- const srcDir = lang_utils_1.ensureString(deriver.srcDir);
116
+ const srcDir = (0, lang_utils_1.ensureString)(deriver.srcDir);
117
117
  const getDefaultAnswer = (name, defaultAnswer) => {
118
118
  // Try to get the user CLI arg override first
119
119
  if (opts[name]) {
@@ -140,8 +140,8 @@ function deriveInitAnswers(opts) {
140
140
  codeScheme: getDefaultAnswer("codeScheme", config_utils_1.DEFAULT_CONFIG.code.scheme),
141
141
  styleScheme: getDefaultAnswer("styleScheme", config_utils_1.DEFAULT_CONFIG.style.scheme),
142
142
  imagesScheme: getDefaultAnswer("imagesScheme", config_utils_1.DEFAULT_CONFIG.images.scheme),
143
- imagesPublicDir: getDefaultAnswer("imagesPublicDir", lang_utils_1.ensure(config_utils_1.DEFAULT_PUBLIC_FILES_CONFIG.publicDir)),
144
- imagesPublicUrlPrefix: getDefaultAnswer("imagesPublicUrlPrefix", lang_utils_1.ensure(config_utils_1.DEFAULT_PUBLIC_FILES_CONFIG.publicUrlPrefix)),
143
+ imagesPublicDir: getDefaultAnswer("imagesPublicDir", (0, lang_utils_1.ensure)(config_utils_1.DEFAULT_PUBLIC_FILES_CONFIG.publicDir)),
144
+ imagesPublicUrlPrefix: getDefaultAnswer("imagesPublicUrlPrefix", (0, lang_utils_1.ensure)(config_utils_1.DEFAULT_PUBLIC_FILES_CONFIG.publicUrlPrefix)),
145
145
  srcDir: getDefaultAnswer("srcDir", config_utils_1.DEFAULT_CONFIG.srcDir),
146
146
  plasmicDir: getDefaultAnswer("plasmicDir", config_utils_1.DEFAULT_CONFIG.defaultPlasmicDir),
147
147
  pagesDir: getDefaultAnswer("pagesDir", undefined),
@@ -189,8 +189,8 @@ function deriveInitAnswers(opts) {
189
189
  // Proceed with platform-specific prompts
190
190
  function maybePrompt(question) {
191
191
  return __awaiter(this, void 0, void 0, function* () {
192
- const name = lang_utils_1.ensure(question.name);
193
- const message = lang_utils_1.ensure(question.message);
192
+ const name = (0, lang_utils_1.ensure)(question.name);
193
+ const message = (0, lang_utils_1.ensure)(question.message);
194
194
  if (opts[name]) {
195
195
  deps_1.logger.info(message + answers[name] + "(specified in CLI arg)");
196
196
  }
@@ -214,7 +214,7 @@ function deriveInitAnswers(opts) {
214
214
  name: "plasmicDir",
215
215
  message: `${getInitArgsQuestion("plasmicDir")} (This is relative to "${answers.srcDir}")\n>`,
216
216
  });
217
- if (config_utils_1.isPageAwarePlatform(platform)) {
217
+ if ((0, config_utils_1.isPageAwarePlatform)(platform)) {
218
218
  yield maybePrompt({
219
219
  name: "pagesDir",
220
220
  message: `${getInitArgsQuestion("pagesDir")} (This is relative to "${answers.srcDir}")\n>`,
@@ -287,7 +287,7 @@ function deriveInitAnswers(opts) {
287
287
  }
288
288
  function getNextDefaults(plasmicRootDir, appDir) {
289
289
  var _a;
290
- const projectRootDir = (_a = npm_utils_1.findPackageJsonDir(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
290
+ const projectRootDir = (_a = (0, npm_utils_1.findPackageJsonDir)(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
291
291
  return {
292
292
  srcDir: upath_1.default.relative(plasmicRootDir, upath_1.default.join(projectRootDir, "components")),
293
293
  pagesDir: (srcDir) => upath_1.default.relative(upath_1.default.join(plasmicRootDir, srcDir), upath_1.default.join(projectRootDir, appDir ? "app" : "pages")),
@@ -305,7 +305,7 @@ function getNextDefaults(plasmicRootDir, appDir) {
305
305
  }
306
306
  function getGatsbyDefaults(plasmicRootDir) {
307
307
  var _a;
308
- const projectRootDir = (_a = npm_utils_1.findPackageJsonDir(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
308
+ const projectRootDir = (_a = (0, npm_utils_1.findPackageJsonDir)(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
309
309
  return {
310
310
  srcDir: upath_1.default.relative(plasmicRootDir, upath_1.default.join(projectRootDir, "src", "components")),
311
311
  pagesDir: (srcDir) => {
@@ -323,7 +323,7 @@ function getGatsbyDefaults(plasmicRootDir) {
323
323
  }
324
324
  function getCraDefaults(plasmicRootDir) {
325
325
  var _a;
326
- const projectRootDir = (_a = npm_utils_1.findPackageJsonDir(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
326
+ const projectRootDir = (_a = (0, npm_utils_1.findPackageJsonDir)(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
327
327
  return {
328
328
  srcDir: upath_1.default.relative(plasmicRootDir, upath_1.default.join(projectRootDir, "src", "components")),
329
329
  styleScheme: "css-modules",
@@ -334,8 +334,8 @@ function getCraDefaults(plasmicRootDir) {
334
334
  }
335
335
  function getGenericDefaults(plasmicRootDir) {
336
336
  var _a;
337
- const projectRootDir = (_a = npm_utils_1.findPackageJsonDir(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
338
- const srcDir = file_utils_1.existsBuffered(upath_1.default.join(projectRootDir, "src"))
337
+ const projectRootDir = (_a = (0, npm_utils_1.findPackageJsonDir)(plasmicRootDir)) !== null && _a !== void 0 ? _a : plasmicRootDir;
338
+ const srcDir = (0, file_utils_1.existsBuffered)(upath_1.default.join(projectRootDir, "src"))
339
339
  ? upath_1.default.join(projectRootDir, "src", "components")
340
340
  : upath_1.default.join(projectRootDir, "components");
341
341
  return {
@@ -453,16 +453,16 @@ exports.getInitArgsChoices = getInitArgsChoices;
453
453
  * @returns
454
454
  */
455
455
  function getYargsOption(key, defaultOverride) {
456
- const arg = lang_utils_1.ensure(INIT_ARGS_DESCRIPTION[key]);
456
+ const arg = (0, lang_utils_1.ensure)(INIT_ARGS_DESCRIPTION[key]);
457
457
  return !arg.choices
458
458
  ? {
459
- describe: lang_utils_1.ensure(getInitArgsLongDescription(key)),
459
+ describe: (0, lang_utils_1.ensure)(getInitArgsLongDescription(key)),
460
460
  string: true,
461
461
  default: defaultOverride !== null && defaultOverride !== void 0 ? defaultOverride : "",
462
462
  }
463
463
  : {
464
- describe: lang_utils_1.ensure(getInitArgsLongDescription(key)),
465
- choices: ["", ...lang_utils_1.ensure(getInitArgsChoices(key))],
464
+ describe: (0, lang_utils_1.ensure)(getInitArgsLongDescription(key)),
465
+ choices: ["", ...(0, lang_utils_1.ensure)(getInitArgsChoices(key))],
466
466
  default: defaultOverride !== null && defaultOverride !== void 0 ? defaultOverride : "",
467
467
  };
468
468
  }
@@ -26,12 +26,36 @@ const user_utils_1 = require("../utils/user-utils");
26
26
  function localizationStrings(opts) {
27
27
  var _a, _b, _c;
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
- if (!opts.projects || opts.projects.length === 0) {
29
+ if (!opts.baseDir) {
30
+ opts.baseDir = process.cwd();
31
+ }
32
+ const maybeConfigFile = opts.config || (0, config_utils_1.findConfigFile)(opts.baseDir, { traverseParents: true });
33
+ let projectSpecs = opts.projects;
34
+ let keyScheme = opts.keyScheme;
35
+ let tagPrefix = opts.tagPrefix;
36
+ const projectTokensFromConfig = [];
37
+ if (maybeConfigFile) {
38
+ // if plasmic.json exists, then we can derive some settings from
39
+ // there instead.
40
+ deps_1.logger.info(`Using settings from ${maybeConfigFile}...`);
41
+ const context = yield (0, get_context_1.getContext)(opts, { enableSkipAuth: true });
42
+ context.config.projects.forEach((p) => {
43
+ projectTokensFromConfig.push((0, lodash_1.pick)(p, "projectId", "projectApiToken"));
44
+ });
45
+ if (!projectSpecs || projectSpecs.length === 0) {
46
+ projectSpecs = context.config.projects.map((p) => p.projectId + (p.version === "latest" ? "" : `@${p.version}`));
47
+ }
48
+ if (!keyScheme) {
49
+ keyScheme = (_a = context.config.i18n) === null || _a === void 0 ? void 0 : _a.keyScheme;
50
+ }
51
+ if (!tagPrefix) {
52
+ tagPrefix = (_b = context.config.i18n) === null || _b === void 0 ? void 0 : _b.tagPrefix;
53
+ }
54
+ }
55
+ if (!projectSpecs || projectSpecs.length === 0) {
30
56
  throw new lib_1.HandledError(`Missing projects.`);
31
57
  }
32
- if (!opts.baseDir)
33
- opts.baseDir = process.cwd();
34
- const parsedProjectTokens = ((_a = opts.projectTokens) !== null && _a !== void 0 ? _a : []).map((val) => {
58
+ const parsedProjectTokens = ((_c = opts.projectTokens) !== null && _c !== void 0 ? _c : []).map((val) => {
35
59
  const [projectId, projectApiToken] = val.split(":");
36
60
  if (!projectId || !projectApiToken) {
37
61
  throw new Error(`Invalid value passed to '--project-tokens': ${val}\nPlease provide the API tokens with the format PROJECT_ID:PROJECT_API_TOKEN`);
@@ -46,23 +70,7 @@ function localizationStrings(opts) {
46
70
  ? "data.po"
47
71
  : "data.json"
48
72
  : opts.output;
49
- let keyScheme = opts.keyScheme;
50
- let tagPrefix = opts.tagPrefix;
51
- const projectTokensFromConfig = [];
52
- const auth = yield auth_utils_1.getCurrentAuth(opts.auth);
53
- const maybeConfigFile = opts.config || config_utils_1.findConfigFile(opts.baseDir, { traverseParents: true });
54
- if (maybeConfigFile) {
55
- const context = yield get_context_1.getContext(opts, { enableSkipAuth: true });
56
- context.config.projects.forEach((p) => {
57
- projectTokensFromConfig.push(lodash_1.pick(p, "projectId", "projectApiToken"));
58
- });
59
- if (!keyScheme) {
60
- keyScheme = (_b = context.config.i18n) === null || _b === void 0 ? void 0 : _b.keyScheme;
61
- }
62
- if (!tagPrefix) {
63
- tagPrefix = (_c = context.config.i18n) === null || _c === void 0 ? void 0 : _c.tagPrefix;
64
- }
65
- }
73
+ const auth = yield (0, auth_utils_1.getCurrentAuth)(opts.auth);
66
74
  const projectIdsAndTokens = [
67
75
  ...parsedProjectTokens,
68
76
  ...projectTokensFromConfig,
@@ -73,15 +81,15 @@ function localizationStrings(opts) {
73
81
  user: "",
74
82
  token: "",
75
83
  });
76
- deps_1.logger.info(`Generating localization strings for ${chalk_1.default.bold(opts.projects.join(", "))}...`);
77
- const data = yield api.genLocalizationStrings(opts.projects, opts.format, keyScheme !== null && keyScheme !== void 0 ? keyScheme : "content", tagPrefix, projectIdsAndTokens, opts.excludeDeps);
78
- if (file_utils_1.existsBuffered(output)) {
79
- const overwrite = yield user_utils_1.confirmWithUser(`File ${output} already exists. Do you want to overwrite?`, opts.forceOverwrite);
84
+ deps_1.logger.info(`Generating localization strings for ${chalk_1.default.bold(projectSpecs.join(", "))}...`);
85
+ const data = yield api.genLocalizationStrings(projectSpecs, opts.format, keyScheme !== null && keyScheme !== void 0 ? keyScheme : "content", tagPrefix, projectIdsAndTokens, opts.excludeDeps);
86
+ if ((0, file_utils_1.existsBuffered)(output)) {
87
+ const overwrite = yield (0, user_utils_1.confirmWithUser)(`File ${output} already exists. Do you want to overwrite?`, opts.forceOverwrite);
80
88
  if (!overwrite) {
81
89
  throw new lib_1.HandledError(`Cannot write to ${output}; file already exists.`);
82
90
  }
83
91
  }
84
- file_utils_1.writeFileText(output, data);
92
+ (0, file_utils_1.writeFileText)(output, data);
85
93
  deps_1.logger.info(`Localization strings have been written to ${output}`);
86
94
  }
87
95
  else {
@@ -2,5 +2,5 @@ export interface ProjectTokenArgs {
2
2
  projectId: string;
3
3
  host: string;
4
4
  }
5
- export declare const getProjectApiToken: (projectId: string, host?: string | undefined) => Promise<string | undefined>;
5
+ export declare const getProjectApiToken: (projectId: string, host?: string) => Promise<string | undefined>;
6
6
  export declare const projectToken: (args: ProjectTokenArgs) => Promise<void>;
@@ -18,9 +18,9 @@ const api_1 = require("../api");
18
18
  const deps_1 = require("../deps");
19
19
  const auth_utils_1 = require("../utils/auth-utils");
20
20
  const config_utils_1 = require("../utils/config-utils");
21
- exports.getProjectApiToken = (projectId, host) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const getProjectApiToken = (projectId, host) => __awaiter(void 0, void 0, void 0, function* () {
22
22
  var _a;
23
- const auth = yield auth_utils_1.getOrStartAuth({
23
+ const auth = yield (0, auth_utils_1.getOrStartAuth)({
24
24
  host: host || config_utils_1.DEFAULT_HOST,
25
25
  baseDir: "",
26
26
  });
@@ -33,10 +33,12 @@ exports.getProjectApiToken = (projectId, host) => __awaiter(void 0, void 0, void
33
33
  }
34
34
  return undefined;
35
35
  });
36
- exports.projectToken = (args) => __awaiter(void 0, void 0, void 0, function* () {
36
+ exports.getProjectApiToken = getProjectApiToken;
37
+ const projectToken = (args) => __awaiter(void 0, void 0, void 0, function* () {
37
38
  const { projectId, host } = args;
38
- const projectApiToken = yield exports.getProjectApiToken(projectId, host);
39
+ const projectApiToken = yield (0, exports.getProjectApiToken)(projectId, host);
39
40
  deps_1.logger.info(`Generated projectApiToken for ${chalk_1.default.bold(projectId)}:`);
40
41
  deps_1.logger.info(chalk_1.default.bold(projectApiToken));
41
42
  deps_1.logger.warn(`Be careful with this token, anyone can have access to your project with it`);
42
43
  });
44
+ exports.projectToken = projectToken;
@@ -37,17 +37,17 @@ function syncProjectComponents(context, project, version, componentBundles, forc
37
37
  const deletedComponentFiles = new Set();
38
38
  for (const deletedComponent of deletedComponents) {
39
39
  const componentConfig = allCompConfigs[deletedComponent.id];
40
- if (file_utils_1.fileExists(context, componentConfig.renderModuleFilePath) &&
41
- file_utils_1.fileExists(context, componentConfig.cssFilePath)) {
40
+ if ((0, file_utils_1.fileExists)(context, componentConfig.renderModuleFilePath) &&
41
+ (0, file_utils_1.fileExists)(context, componentConfig.cssFilePath)) {
42
42
  deps_1.logger.info(`Deleting component: ${componentConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${componentConfig.id} ${project.version}]`);
43
- file_utils_1.deleteFile(context, componentConfig.renderModuleFilePath);
44
- file_utils_1.deleteFile(context, componentConfig.cssFilePath);
43
+ (0, file_utils_1.deleteFile)(context, componentConfig.renderModuleFilePath);
44
+ (0, file_utils_1.deleteFile)(context, componentConfig.cssFilePath);
45
45
  deletedComponentFiles.add(deletedComponent.id);
46
46
  const skeletonPath = componentConfig.importSpec.modulePath;
47
- if (file_utils_1.fileExists(context, skeletonPath)) {
48
- const deleteSkeleton = yield user_utils_1.confirmWithUser(`Do you want to delete ${skeletonPath}?`, context.cliArgs.yes);
47
+ if ((0, file_utils_1.fileExists)(context, skeletonPath)) {
48
+ const deleteSkeleton = yield (0, user_utils_1.confirmWithUser)(`Do you want to delete ${skeletonPath}?`, context.cliArgs.yes);
49
49
  if (deleteSkeleton) {
50
- file_utils_1.deleteFile(context, skeletonPath);
50
+ (0, file_utils_1.deleteFile)(context, skeletonPath);
51
51
  }
52
52
  }
53
53
  }
@@ -67,10 +67,10 @@ function syncProjectComponents(context, project, version, componentBundles, forc
67
67
  const shouldRegenerate = (compConfig === null || compConfig === void 0 ? void 0 : compConfig.name) !== componentName;
68
68
  let skeletonModuleModified = shouldRegenerate;
69
69
  const skeletonPath = isPage
70
- ? file_utils_1.defaultPagePath(context, skeletonModuleFileName)
70
+ ? (0, file_utils_1.defaultPagePath)(context, skeletonModuleFileName)
71
71
  : skeletonModuleFileName;
72
- const defaultRenderModuleFilePath = file_utils_1.defaultResourcePath(context, project, renderModuleFileName);
73
- const defaultCssFilePath = file_utils_1.defaultResourcePath(context, project, cssFileName);
72
+ const defaultRenderModuleFilePath = (0, file_utils_1.defaultResourcePath)(context, project, renderModuleFileName);
73
+ const defaultCssFilePath = (0, file_utils_1.defaultResourcePath)(context, project, cssFileName);
74
74
  if (shouldRegenerate) {
75
75
  project.components = project.components.filter((existingComponent) => existingComponent.id !== id);
76
76
  compConfig = {
@@ -88,7 +88,7 @@ function syncProjectComponents(context, project, version, componentBundles, forc
88
88
  allCompConfigs[id] = compConfig;
89
89
  project.components.push(allCompConfigs[id]);
90
90
  // Because it's the first time, we also generate the skeleton file.
91
- yield file_utils_1.writeFileContent(context, skeletonPath, skeletonModule, {
91
+ yield (0, file_utils_1.writeFileContent)(context, skeletonPath, skeletonModule, {
92
92
  force: false,
93
93
  });
94
94
  }
@@ -101,7 +101,7 @@ function syncProjectComponents(context, project, version, componentBundles, forc
101
101
  // Read in the existing file
102
102
  let editedFile;
103
103
  try {
104
- editedFile = file_utils_1.readFileContent(context, compConfig.importSpec.modulePath);
104
+ editedFile = (0, file_utils_1.readFileContent)(context, compConfig.importSpec.modulePath);
105
105
  }
106
106
  catch (e) {
107
107
  deps_1.logger.warn(`${compConfig.importSpec.modulePath} is missing. If you deleted this component, remember to remove the component from ${config_utils_1.CONFIG_FILE_NAME}`);
@@ -109,30 +109,30 @@ function syncProjectComponents(context, project, version, componentBundles, forc
109
109
  }
110
110
  const renderModuleFilePath = upath_1.default.join(upath_1.default.dirname(compConfig.renderModuleFilePath), upath_1.default.basename(defaultRenderModuleFilePath));
111
111
  if (compConfig.renderModuleFilePath !== renderModuleFilePath &&
112
- file_utils_1.fileExists(context, compConfig.renderModuleFilePath)) {
112
+ (0, file_utils_1.fileExists)(context, compConfig.renderModuleFilePath)) {
113
113
  if (context.cliArgs.quiet !== true) {
114
114
  deps_1.logger.info(`Renaming component file: ${compConfig.renderModuleFilePath}@${version}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
115
115
  }
116
- file_utils_1.renameFile(context, compConfig.renderModuleFilePath, renderModuleFilePath);
116
+ (0, file_utils_1.renameFile)(context, compConfig.renderModuleFilePath, renderModuleFilePath);
117
117
  compConfig.renderModuleFilePath = renderModuleFilePath;
118
118
  }
119
119
  const cssFilePath = upath_1.default.join(upath_1.default.dirname(compConfig.cssFilePath), upath_1.default.basename(defaultCssFilePath));
120
120
  if (compConfig.cssFilePath !== cssFilePath &&
121
- file_utils_1.fileExists(context, compConfig.cssFilePath)) {
121
+ (0, file_utils_1.fileExists)(context, compConfig.cssFilePath)) {
122
122
  if (context.cliArgs.quiet !== true) {
123
123
  deps_1.logger.info(`Renaming component css file: ${compConfig.cssFilePath}@${version}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
124
124
  }
125
- file_utils_1.renameFile(context, compConfig.cssFilePath, cssFilePath);
125
+ (0, file_utils_1.renameFile)(context, compConfig.cssFilePath, cssFilePath);
126
126
  compConfig.cssFilePath = cssFilePath;
127
127
  }
128
128
  if (isPage &&
129
- config_utils_1.isPageAwarePlatform(context.config.platform) &&
130
- !file_utils_1.eqPagePath(skeletonPath, compConfig.importSpec.modulePath) &&
131
- file_utils_1.fileExists(context, compConfig.importSpec.modulePath)) {
129
+ (0, config_utils_1.isPageAwarePlatform)(context.config.platform) &&
130
+ !(0, file_utils_1.eqPagePath)(skeletonPath, compConfig.importSpec.modulePath) &&
131
+ (0, file_utils_1.fileExists)(context, compConfig.importSpec.modulePath)) {
132
132
  if (context.cliArgs.quiet !== true) {
133
133
  deps_1.logger.info(`Renaming page file: ${compConfig.importSpec.modulePath} -> ${skeletonPath}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
134
134
  }
135
- file_utils_1.renameFile(context, compConfig.importSpec.modulePath, skeletonPath);
135
+ (0, file_utils_1.renameFile)(context, compConfig.importSpec.modulePath, skeletonPath);
136
136
  compConfig.importSpec.modulePath = skeletonPath;
137
137
  }
138
138
  compConfig.plumeType = plumeType;
@@ -142,7 +142,7 @@ function syncProjectComponents(context, project, version, componentBundles, forc
142
142
  else if (/\/\/\s*plasmic-managed-jsx\/\d+/.test(editedFile)) {
143
143
  if (forceOverwrite) {
144
144
  skeletonModuleModified = true;
145
- yield file_utils_1.writeFileContent(context, compConfig.importSpec.modulePath, skeletonModule, {
145
+ yield (0, file_utils_1.writeFileContent)(context, compConfig.importSpec.modulePath, skeletonModule, {
146
146
  force: true,
147
147
  });
148
148
  }
@@ -151,35 +151,35 @@ function syncProjectComponents(context, project, version, componentBundles, forc
151
151
  }
152
152
  }
153
153
  }
154
- lang_utils_1.assert(lodash_1.default.isArray(projectLock.fileLocks));
154
+ (0, lang_utils_1.assert)(lodash_1.default.isArray(projectLock.fileLocks));
155
155
  // Update FileLocks
156
156
  if (renderModuleFileLocks[id]) {
157
- renderModuleFileLocks[id].checksum = lang_utils_1.ensure(id2RenderModuleChecksum.get(id));
157
+ renderModuleFileLocks[id].checksum = (0, lang_utils_1.ensure)(id2RenderModuleChecksum.get(id));
158
158
  }
159
159
  else {
160
160
  projectLock.fileLocks.push({
161
161
  type: "renderModule",
162
162
  assetId: id,
163
- checksum: lang_utils_1.ensure(id2RenderModuleChecksum.get(id)),
163
+ checksum: (0, lang_utils_1.ensure)(id2RenderModuleChecksum.get(id)),
164
164
  });
165
165
  }
166
166
  if (cssRulesFileLocks[id]) {
167
- cssRulesFileLocks[id].checksum = lang_utils_1.ensure(id2CssRulesChecksum.get(id));
167
+ cssRulesFileLocks[id].checksum = (0, lang_utils_1.ensure)(id2CssRulesChecksum.get(id));
168
168
  }
169
169
  else {
170
170
  projectLock.fileLocks.push({
171
171
  type: "cssRules",
172
172
  assetId: id,
173
- checksum: lang_utils_1.ensure(id2CssRulesChecksum.get(id)),
173
+ checksum: (0, lang_utils_1.ensure)(id2CssRulesChecksum.get(id)),
174
174
  });
175
175
  }
176
176
  if (compConfig.type === "managed") {
177
177
  // Again, only need to touch files on disk if managed
178
- yield file_utils_1.writeFileContent(context, compConfig.renderModuleFilePath, renderModule, {
178
+ yield (0, file_utils_1.writeFileContent)(context, compConfig.renderModuleFilePath, renderModule, {
179
179
  force: !shouldRegenerate,
180
180
  });
181
- const formattedCssRules = code_utils_1.formatAsLocal(cssRules, compConfig.cssFilePath, baseDir);
182
- yield file_utils_1.writeFileContent(context, compConfig.cssFilePath, formattedCssRules, {
181
+ const formattedCssRules = (0, code_utils_1.formatAsLocal)(cssRules, compConfig.cssFilePath, baseDir);
182
+ yield (0, file_utils_1.writeFileContent)(context, compConfig.cssFilePath, formattedCssRules, {
183
183
  force: !shouldRegenerate,
184
184
  });
185
185
  }
@@ -26,9 +26,9 @@ function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, ch
26
26
  deps_1.logger.info(`Syncing component: ${COMPONENT_NAME}@${projectLock.version}\t['${projectConfig.projectName}' ${projectConfig.projectId} ${projectConfig.version}]`);
27
27
  }
28
28
  if (context.config.code.lang === "js") {
29
- projectMeta.globalContextBundle.contextModule = code_utils_1.formatScript(code_utils_1.tsxToJsx(projectMeta.globalContextBundle.contextModule), baseDir);
29
+ projectMeta.globalContextBundle.contextModule = (0, code_utils_1.formatScript)((0, code_utils_1.tsxToJsx)(projectMeta.globalContextBundle.contextModule), baseDir);
30
30
  }
31
- file_utils_1.writeFileContent(context, resourcePath, projectMeta.globalContextBundle.contextModule, { force: true });
31
+ (0, file_utils_1.writeFileContent)(context, resourcePath, projectMeta.globalContextBundle.contextModule, { force: true });
32
32
  projectConfig.globalContextsFilePath = resourcePath;
33
33
  const fl = projectLock.fileLocks.find((fl) => fl.assetId === projectConfig.projectId && fl.type === "globalContexts");
34
34
  if (fl) {
@@ -44,8 +44,8 @@ function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, ch
44
44
  }
45
45
  else if (!checksums.globalContextsChecksum &&
46
46
  !projectMeta.globalContextBundle) {
47
- if (file_utils_1.fileExists(context, resourcePath)) {
48
- file_utils_1.deleteFile(context, resourcePath);
47
+ if ((0, file_utils_1.fileExists)(context, resourcePath)) {
48
+ (0, file_utils_1.deleteFile)(context, resourcePath);
49
49
  }
50
50
  projectConfig.globalContextsFilePath = "";
51
51
  lodash_1.default.remove(projectLock.fileLocks, (fl) => fl.assetId === projectConfig.projectId && fl.type === "globalContexts");
@@ -56,6 +56,6 @@ exports.syncGlobalContexts = syncGlobalContexts;
56
56
  function getGlobalContextsResourcePath(context, projectConfig) {
57
57
  return projectConfig.globalContextsFilePath !== ""
58
58
  ? projectConfig.globalContextsFilePath
59
- : file_utils_1.defaultResourcePath(context, projectConfig, `${COMPONENT_NAME}.${context.config.code.lang === "ts" ? "tsx" : "jsx"}`);
59
+ : (0, file_utils_1.defaultResourcePath)(context, projectConfig, `${COMPONENT_NAME}.${context.config.code.lang === "ts" ? "tsx" : "jsx"}`);
60
60
  }
61
61
  exports.getGlobalContextsResourcePath = getGlobalContextsResourcePath;
@@ -23,7 +23,7 @@ const lang_utils_1 = require("../utils/lang-utils");
23
23
  function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName, baseDir) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const projectId = projectMeta.projectId;
26
- const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
26
+ const projectLock = (0, config_utils_1.getOrAddProjectLock)(context, projectId, branchName);
27
27
  const existingVariantConfigs = lodash_1.default.keyBy(context.config.globalVariants.variantGroups.filter((group) => group.projectId === projectId), (c) => c.id);
28
28
  const globalVariantFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "globalVariant"), (fl) => fl.assetId);
29
29
  const id2VariantChecksum = new Map(checksums.globalVariantChecksums);
@@ -35,7 +35,7 @@ function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName
35
35
  }
36
36
  let variantConfig = existingVariantConfigs[bundle.id];
37
37
  const isNew = !variantConfig;
38
- const defaultContextFilePath = file_utils_1.defaultResourcePath(context, projectMeta, bundle.contextFileName);
38
+ const defaultContextFilePath = (0, file_utils_1.defaultResourcePath)(context, projectMeta, bundle.contextFileName);
39
39
  if (isNew) {
40
40
  variantConfig = {
41
41
  id: bundle.id,
@@ -49,34 +49,34 @@ function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName
49
49
  else {
50
50
  const contextFilePath = upath_1.default.join(upath_1.default.dirname(variantConfig.contextFilePath), upath_1.default.basename(defaultContextFilePath));
51
51
  if (variantConfig.contextFilePath !== contextFilePath &&
52
- file_utils_1.fileExists(context, variantConfig.contextFilePath)) {
52
+ (0, file_utils_1.fileExists)(context, variantConfig.contextFilePath)) {
53
53
  if (context.cliArgs.quiet !== true) {
54
54
  deps_1.logger.info(`Renaming global variant: ${variantConfig.name} [${projectId}/${bundle.id}]`);
55
55
  }
56
- file_utils_1.renameFile(context, variantConfig.contextFilePath, contextFilePath);
56
+ (0, file_utils_1.renameFile)(context, variantConfig.contextFilePath, contextFilePath);
57
57
  variantConfig.contextFilePath = contextFilePath;
58
58
  }
59
59
  variantConfig.name = bundle.name;
60
60
  }
61
61
  // Update FileLocks
62
62
  if (globalVariantFileLocks[bundle.id]) {
63
- globalVariantFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2VariantChecksum.get(bundle.id));
63
+ globalVariantFileLocks[bundle.id].checksum = (0, lang_utils_1.ensure)(id2VariantChecksum.get(bundle.id));
64
64
  }
65
65
  else {
66
66
  projectLock.fileLocks.push({
67
67
  type: "globalVariant",
68
68
  assetId: bundle.id,
69
- checksum: lang_utils_1.ensure(id2VariantChecksum.get(bundle.id)),
69
+ checksum: (0, lang_utils_1.ensure)(id2VariantChecksum.get(bundle.id)),
70
70
  });
71
71
  }
72
- yield file_utils_1.writeFileContent(context, variantConfig.contextFilePath, code_utils_1.formatAsLocal(bundle.contextModule, variantConfig.contextFilePath, baseDir), { force: !isNew });
72
+ yield (0, file_utils_1.writeFileContent)(context, variantConfig.contextFilePath, (0, code_utils_1.formatAsLocal)(bundle.contextModule, variantConfig.contextFilePath, baseDir), { force: !isNew });
73
73
  }
74
74
  const deletedVariantsFiles = new Set();
75
75
  for (const deletedGlobalVariant of deletedGlobalVariants) {
76
76
  const variantConfig = existingVariantConfigs[deletedGlobalVariant.id];
77
- if (file_utils_1.fileExists(context, variantConfig.contextFilePath)) {
77
+ if ((0, file_utils_1.fileExists)(context, variantConfig.contextFilePath)) {
78
78
  deps_1.logger.info(`Deleting global variant: ${variantConfig.name} [${projectId}/${deletedGlobalVariant.id}]`);
79
- file_utils_1.deleteFile(context, variantConfig.contextFilePath);
79
+ (0, file_utils_1.deleteFile)(context, variantConfig.contextFilePath);
80
80
  deletedVariantsFiles.add(deletedGlobalVariant.id);
81
81
  }
82
82
  }
@@ -22,11 +22,11 @@ const file_utils_1 = require("../utils/file-utils");
22
22
  const lang_utils_1 = require("../utils/lang-utils");
23
23
  function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums, baseDir) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- const project = config_utils_1.getOrAddProjectConfig(context, projectId);
25
+ const project = (0, config_utils_1.getOrAddProjectConfig)(context, projectId);
26
26
  if (!project.icons) {
27
27
  project.icons = [];
28
28
  }
29
- const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
29
+ const projectLock = (0, config_utils_1.getOrAddProjectLock)(context, projectId, branchName);
30
30
  const knownIconConfigs = lodash_1.default.keyBy(project.icons, (i) => i.id);
31
31
  const iconFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "icon"), (fl) => fl.assetId);
32
32
  const id2IconChecksum = new Map(checksums.iconChecksums);
@@ -38,7 +38,7 @@ function syncProjectIconAssets(context, projectId, branchName, version, iconBund
38
38
  }
39
39
  let iconConfig = knownIconConfigs[bundle.id];
40
40
  const isNew = !iconConfig;
41
- const defaultModuleFilePath = file_utils_1.defaultResourcePath(context, project, "icons", bundle.fileName);
41
+ const defaultModuleFilePath = (0, file_utils_1.defaultResourcePath)(context, project, "icons", bundle.fileName);
42
42
  if (isNew) {
43
43
  iconConfig = {
44
44
  id: bundle.id,
@@ -51,36 +51,36 @@ function syncProjectIconAssets(context, projectId, branchName, version, iconBund
51
51
  else {
52
52
  const moduleFilePath = upath_1.default.join(upath_1.default.dirname(iconConfig.moduleFilePath), upath_1.default.basename(defaultModuleFilePath));
53
53
  if (iconConfig.moduleFilePath !== moduleFilePath &&
54
- file_utils_1.fileExists(context, iconConfig.moduleFilePath)) {
54
+ (0, file_utils_1.fileExists)(context, iconConfig.moduleFilePath)) {
55
55
  if (context.cliArgs.quiet !== true) {
56
56
  deps_1.logger.info(`Renaming icon: ${iconConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
57
57
  }
58
- file_utils_1.renameFile(context, iconConfig.moduleFilePath, moduleFilePath);
58
+ (0, file_utils_1.renameFile)(context, iconConfig.moduleFilePath, moduleFilePath);
59
59
  iconConfig.moduleFilePath = moduleFilePath;
60
60
  }
61
61
  iconConfig.name = bundle.name;
62
62
  }
63
63
  // Update FileLocks
64
64
  if (iconFileLocks[bundle.id]) {
65
- iconFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2IconChecksum.get(bundle.id));
65
+ iconFileLocks[bundle.id].checksum = (0, lang_utils_1.ensure)(id2IconChecksum.get(bundle.id));
66
66
  }
67
67
  else {
68
68
  projectLock.fileLocks.push({
69
69
  type: "icon",
70
70
  assetId: bundle.id,
71
- checksum: lang_utils_1.ensure(id2IconChecksum.get(bundle.id)),
71
+ checksum: (0, lang_utils_1.ensure)(id2IconChecksum.get(bundle.id)),
72
72
  });
73
73
  }
74
- yield file_utils_1.writeFileContent(context, iconConfig.moduleFilePath, code_utils_1.formatAsLocal(bundle.module, iconConfig.moduleFilePath, baseDir), {
74
+ yield (0, file_utils_1.writeFileContent)(context, iconConfig.moduleFilePath, (0, code_utils_1.formatAsLocal)(bundle.module, iconConfig.moduleFilePath, baseDir), {
75
75
  force: !isNew,
76
76
  });
77
77
  }
78
78
  const deletedIconFiles = new Set();
79
79
  for (const deletedIcon of deletedIcons) {
80
80
  const iconConfig = knownIconConfigs[deletedIcon.id];
81
- if (file_utils_1.fileExists(context, iconConfig.moduleFilePath)) {
81
+ if ((0, file_utils_1.fileExists)(context, iconConfig.moduleFilePath)) {
82
82
  deps_1.logger.info(`Deleting icon: ${iconConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${deletedIcon.id} ${project.version}]`);
83
- file_utils_1.deleteFile(context, iconConfig.moduleFilePath);
83
+ (0, file_utils_1.deleteFile)(context, iconConfig.moduleFilePath);
84
84
  deletedIconFiles.add(deletedIcon.id);
85
85
  }
86
86
  }