@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
@@ -24,8 +24,8 @@ const file_utils_1 = require("../utils/file-utils");
24
24
  const lang_utils_1 = require("../utils/lang-utils");
25
25
  function syncProjectImageAssets(context, projectId, branchName, version, imageBundles, checksums) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- const project = config_utils_1.getOrAddProjectConfig(context, projectId);
28
- const projectLock = config_utils_1.getOrAddProjectLock(context, projectId, branchName);
27
+ const project = (0, config_utils_1.getOrAddProjectConfig)(context, projectId);
28
+ const projectLock = (0, config_utils_1.getOrAddProjectLock)(context, projectId, branchName);
29
29
  const knownImageConfigs = lodash_1.default.keyBy(project.images, (i) => i.id);
30
30
  const imageBundleIds = lodash_1.default.keyBy(imageBundles, (i) => i.id);
31
31
  const imageFileLocks = lodash_1.default.keyBy(projectLock.fileLocks.filter((fileLock) => fileLock.type === "image"), (fl) => fl.assetId);
@@ -39,8 +39,8 @@ function syncProjectImageAssets(context, projectId, branchName, version, imageBu
39
39
  let imageConfig = knownImageConfigs[bundle.id];
40
40
  const isNew = !imageConfig;
41
41
  const defaultFilePath = context.config.images.scheme === "public-files"
42
- ? file_utils_1.defaultPublicResourcePath(context, project, "images", bundle.fileName)
43
- : file_utils_1.defaultResourcePath(context, project, "images", bundle.fileName);
42
+ ? (0, file_utils_1.defaultPublicResourcePath)(context, project, "images", bundle.fileName)
43
+ : (0, file_utils_1.defaultResourcePath)(context, project, "images", bundle.fileName);
44
44
  if (isNew) {
45
45
  imageConfig = {
46
46
  id: bundle.id,
@@ -52,36 +52,36 @@ function syncProjectImageAssets(context, projectId, branchName, version, imageBu
52
52
  else {
53
53
  const filePath = upath_1.default.join(upath_1.default.dirname(imageConfig.filePath), upath_1.default.basename(defaultFilePath));
54
54
  if (imageConfig.filePath !== filePath &&
55
- file_utils_1.fileExists(context, imageConfig.filePath)) {
55
+ (0, file_utils_1.fileExists)(context, imageConfig.filePath)) {
56
56
  if (context.cliArgs.quiet !== true) {
57
57
  deps_1.logger.info(`Renaming image: ${imageConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${bundle.id} ${project.version}]`);
58
58
  }
59
- file_utils_1.renameFile(context, imageConfig.filePath, filePath);
59
+ (0, file_utils_1.renameFile)(context, imageConfig.filePath, filePath);
60
60
  imageConfig.filePath = filePath;
61
61
  }
62
62
  imageConfig.name = bundle.name;
63
63
  }
64
64
  // Update FileLocks
65
65
  if (imageFileLocks[bundle.id]) {
66
- imageFileLocks[bundle.id].checksum = lang_utils_1.ensure(id2ImageChecksum.get(bundle.id));
66
+ imageFileLocks[bundle.id].checksum = (0, lang_utils_1.ensure)(id2ImageChecksum.get(bundle.id));
67
67
  }
68
68
  else {
69
69
  projectLock.fileLocks.push({
70
70
  type: "image",
71
71
  assetId: bundle.id,
72
- checksum: lang_utils_1.ensure(id2ImageChecksum.get(bundle.id)),
72
+ checksum: (0, lang_utils_1.ensure)(id2ImageChecksum.get(bundle.id)),
73
73
  });
74
74
  }
75
- yield file_utils_1.writeFileContent(context, imageConfig.filePath, Buffer.from(bundle.blob, "base64"), {
75
+ yield (0, file_utils_1.writeFileContent)(context, imageConfig.filePath, Buffer.from(bundle.blob, "base64"), {
76
76
  force: !isNew,
77
77
  });
78
78
  }
79
79
  const deletedImageFiles = new Set();
80
80
  for (const deletedImage of deletedImages) {
81
81
  const imageConfig = knownImageConfigs[deletedImage.id];
82
- if (file_utils_1.fileExists(context, imageConfig.filePath)) {
82
+ if ((0, file_utils_1.fileExists)(context, imageConfig.filePath)) {
83
83
  deps_1.logger.info(`Deleting image: ${imageConfig.name}@${version}\t['${project.projectName}' ${project.projectId}/${deletedImage.id} ${project.version}]`);
84
- file_utils_1.deleteFile(context, imageConfig.filePath);
84
+ (0, file_utils_1.deleteFile)(context, imageConfig.filePath);
85
85
  deletedImageFiles.add(deletedImage.id);
86
86
  }
87
87
  }
@@ -110,7 +110,7 @@ function ensureImageAssetContents(bundles) {
110
110
  .for(needsFetching)
111
111
  .process((bundle) => __awaiter(this, void 0, void 0, function* () {
112
112
  try {
113
- const res = yield node_fetch_1.default(bundle.blob);
113
+ const res = yield (0, node_fetch_1.default)(bundle.blob);
114
114
  if (res.status !== 200) {
115
115
  throw new Error(`Fetching ${bundle.blob} failed with status ${res.status}`);
116
116
  }
@@ -127,17 +127,17 @@ function ensureImageAssetContents(bundles) {
127
127
  });
128
128
  }
129
129
  function getImagePublicUrl(context, asset) {
130
- return (lang_utils_1.ensure(context.config.images.publicUrlPrefix) +
131
- (lang_utils_1.ensure(context.config.images.publicUrlPrefix).endsWith("/") ? "" : "/") +
132
- upath_1.default.relative(lang_utils_1.ensure(context.config.images.publicDir), asset.filePath));
130
+ return ((0, lang_utils_1.ensure)(context.config.images.publicUrlPrefix) +
131
+ ((0, lang_utils_1.ensure)(context.config.images.publicUrlPrefix).endsWith("/") ? "" : "/") +
132
+ upath_1.default.relative((0, lang_utils_1.ensure)(context.config.images.publicDir), asset.filePath));
133
133
  }
134
134
  const RE_ASSETCSSREF_ALL = /var\(--image-([^\)]+)\)/g;
135
135
  function fixComponentCssReferences(context, fixImportContext, cssFilePath) {
136
136
  return __awaiter(this, void 0, void 0, function* () {
137
- if (!file_utils_1.fileExists(context, cssFilePath)) {
137
+ if (!(0, file_utils_1.fileExists)(context, cssFilePath)) {
138
138
  return;
139
139
  }
140
- const prevContent = file_utils_1.readFileContent(context, cssFilePath);
140
+ const prevContent = (0, file_utils_1.readFileContent)(context, cssFilePath);
141
141
  const newContent = prevContent.replace(RE_ASSETCSSREF_ALL, (sub, assetId) => {
142
142
  const asset = fixImportContext.images[assetId];
143
143
  if (asset) {
@@ -150,7 +150,7 @@ function fixComponentCssReferences(context, fixImportContext, cssFilePath) {
150
150
  }
151
151
  });
152
152
  if (prevContent !== newContent) {
153
- yield file_utils_1.writeFileContent(context, cssFilePath, newContent, { force: true });
153
+ yield (0, file_utils_1.writeFileContent)(context, cssFilePath, newContent, { force: true });
154
154
  }
155
155
  });
156
156
  }
@@ -158,7 +158,7 @@ exports.fixComponentCssReferences = fixComponentCssReferences;
158
158
  const RE_ASSETTSXREF_ALL = /Plasmic_Image_([^\)\s]+)__Ref/g;
159
159
  function fixComponentImagesReferences(context, fixImportContext, renderModuleFilePath) {
160
160
  return __awaiter(this, void 0, void 0, function* () {
161
- const prevContent = file_utils_1.readFileContent(context, renderModuleFilePath);
161
+ const prevContent = (0, file_utils_1.readFileContent)(context, renderModuleFilePath);
162
162
  const newContent = prevContent.replace(RE_ASSETTSXREF_ALL, (sub, assetId) => {
163
163
  const asset = fixImportContext.images[assetId];
164
164
  if (asset) {
@@ -169,7 +169,7 @@ function fixComponentImagesReferences(context, fixImportContext, renderModuleFil
169
169
  }
170
170
  });
171
171
  if (prevContent !== newContent) {
172
- yield file_utils_1.writeFileContent(context, renderModuleFilePath, newContent, {
172
+ yield (0, file_utils_1.writeFileContent)(context, renderModuleFilePath, newContent, {
173
173
  force: true,
174
174
  });
175
175
  // Returns true if the content changed
@@ -38,16 +38,16 @@ function upsertStyleTokens(context, newStyleMap, projectId) {
38
38
  return false;
39
39
  });
40
40
  curStyleMap.props.sort((prop1, prop2) => prop1.name === prop2.name ? 0 : prop1.name < prop2.name ? -1 : 1);
41
- yield file_utils_1.writeFileContent(context, context.config.tokens.tokensFilePath, JSON.stringify(curStyleMap, undefined, 2), { force: true });
41
+ yield (0, file_utils_1.writeFileContent)(context, context.config.tokens.tokensFilePath, JSON.stringify(curStyleMap, undefined, 2), { force: true });
42
42
  });
43
43
  }
44
44
  exports.upsertStyleTokens = upsertStyleTokens;
45
45
  function readCurStyleMap(context) {
46
46
  return __awaiter(this, void 0, void 0, function* () {
47
47
  const filePath = context.config.tokens.tokensFilePath;
48
- if (file_utils_1.fileExists(context, filePath)) {
48
+ if ((0, file_utils_1.fileExists)(context, filePath)) {
49
49
  try {
50
- return JSON.parse(file_utils_1.readFileContent(context, context.config.tokens.tokensFilePath));
50
+ return JSON.parse((0, file_utils_1.readFileContent)(context, context.config.tokens.tokensFilePath));
51
51
  }
52
52
  catch (e) {
53
53
  throw new error_1.HandledError(`Error encountered reading ${context.config.tokens.tokensFilePath}: ${e}`);
@@ -62,7 +62,7 @@ function readCurStyleMap(context) {
62
62
  },
63
63
  },
64
64
  };
65
- yield file_utils_1.writeFileContent(context, context.config.tokens.tokensFilePath, JSON.stringify(defaultMap, undefined, 2), {
65
+ yield (0, file_utils_1.writeFileContent)(context, context.config.tokens.tokensFilePath, JSON.stringify(defaultMap, undefined, 2), {
66
66
  force: false,
67
67
  });
68
68
  return defaultMap;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -60,10 +64,10 @@ function ensureRequiredPackages(context, baseDir, yes) {
60
64
  const requireds = yield context.api.requiredPackages();
61
65
  const confirmInstall = (pkg, requiredVersion, opts) => __awaiter(this, void 0, void 0, function* () {
62
66
  let success = false;
63
- const command = npm_utils_1.installCommand(context.config, pkg, baseDir, opts);
64
- const upgrade = yield user_utils_1.confirmWithUser(`A more recent version of ${pkg} >=${requiredVersion} is required. Would you like to upgrade via "${command}"?`, yes);
67
+ const command = (0, npm_utils_1.installCommand)(context.config, pkg, baseDir, opts);
68
+ const upgrade = yield (0, user_utils_1.confirmWithUser)(`A more recent version of ${pkg} >=${requiredVersion} is required. Would you like to upgrade via "${command}"?`, yes);
65
69
  if (upgrade) {
66
- success = npm_utils_1.installUpgrade(context.config, pkg, baseDir, opts);
70
+ success = (0, npm_utils_1.installUpgrade)(context.config, pkg, baseDir, opts);
67
71
  }
68
72
  else {
69
73
  success = false;
@@ -72,9 +76,9 @@ function ensureRequiredPackages(context, baseDir, yes) {
72
76
  throw new error_1.HandledError(`Upgrading ${pkg} is required to continue.`);
73
77
  }
74
78
  });
75
- const cliVersion = npm_utils_1.getCliVersion();
79
+ const cliVersion = (0, npm_utils_1.getCliVersion)();
76
80
  if (!cliVersion || semver.gt(requireds["@plasmicapp/cli"], cliVersion)) {
77
- const isGlobal = npm_utils_1.isCliGloballyInstalled(context.rootDir);
81
+ const isGlobal = (0, npm_utils_1.isCliGloballyInstalled)(context.rootDir);
78
82
  yield confirmInstall("@plasmicapp/cli", requireds["@plasmicapp/cli"], {
79
83
  global: isGlobal,
80
84
  dev: true,
@@ -83,14 +87,14 @@ function ensureRequiredPackages(context, baseDir, yes) {
83
87
  // Exit so the user can run again with the new cli
84
88
  throw new error_1.HandledError();
85
89
  }
86
- const reactWebVersion = npm_utils_1.findInstalledVersion(context.config, baseDir, "@plasmicapp/react-web");
90
+ const reactWebVersion = (0, npm_utils_1.findInstalledVersion)(context.config, baseDir, "@plasmicapp/react-web");
87
91
  if (!reactWebVersion ||
88
92
  semver.gt(requireds["@plasmicapp/react-web"], reactWebVersion)) {
89
93
  yield confirmInstall("@plasmicapp/react-web", requireds["@plasmicapp/react-web"], { global: false, dev: false });
90
94
  }
91
95
  if (context.config.code.reactRuntime === "automatic") {
92
96
  // Using automatic runtime requires installing the @plasmicapp/react-web-runtime package
93
- const runtimeVersion = npm_utils_1.findInstalledVersion(context.config, baseDir, "@plasmicapp/react-web-runtime");
97
+ const runtimeVersion = (0, npm_utils_1.findInstalledVersion)(context.config, baseDir, "@plasmicapp/react-web-runtime");
94
98
  if (!runtimeVersion ||
95
99
  semver.gt(requireds["@plasmicapp/react-web-runtime"], runtimeVersion)) {
96
100
  yield confirmInstall("@plasmicapp/react-web-runtime", requireds["@plasmicapp/react-web-runtime"], { global: false, dev: false });
@@ -103,14 +107,14 @@ function getLoaderConfigPath(opts) {
103
107
  }
104
108
  function maybeReadLoaderConfig(opts) {
105
109
  const path = getLoaderConfigPath(opts);
106
- if (!file_utils_1.existsBuffered(path)) {
110
+ if (!(0, file_utils_1.existsBuffered)(path)) {
107
111
  return {};
108
112
  }
109
- return JSON.parse(file_utils_1.readFileText(path));
113
+ return JSON.parse((0, file_utils_1.readFileText)(path));
110
114
  }
111
115
  function writeLoaderConfig(opts, config) {
112
116
  const loaderConfigPath = getLoaderConfigPath(opts);
113
- file_utils_1.writeFileText(loaderConfigPath, code_utils_1.formatAsLocal(JSON.stringify(config), loaderConfigPath, opts.baseDir));
117
+ (0, file_utils_1.writeFileText)(loaderConfigPath, (0, code_utils_1.formatAsLocal)(JSON.stringify(config), loaderConfigPath, opts.baseDir));
114
118
  }
115
119
  /**
116
120
  * Sync will always try to sync down a set of components that are version-consistent among specified projects.
@@ -127,19 +131,19 @@ function sync(opts, metadataDefaults) {
127
131
  if (!opts.baseDir)
128
132
  opts.baseDir = process.cwd();
129
133
  const baseDir = opts.baseDir;
130
- let context = yield get_context_1.getContext(opts, { enableSkipAuth: true });
134
+ let context = yield (0, get_context_1.getContext)(opts, { enableSkipAuth: true });
131
135
  const isFirstRun = context.config.projects.length === 0;
132
136
  if (!opts.skipUpgradeCheck) {
133
137
  yield ensureRequiredPackages(context, opts.baseDir, opts.yes);
134
138
  }
135
139
  fixFileExtension(context);
136
- file_utils_1.assertAllPathsInRootDir(context);
140
+ (0, file_utils_1.assertAllPathsInRootDir)(context);
137
141
  const loaderConfig = process.env.PLASMIC_LOADER
138
142
  ? maybeReadLoaderConfig(opts)
139
143
  : {};
140
144
  const projectIdToToken = new Map([...context.config.projects, ...((_a = loaderConfig === null || loaderConfig === void 0 ? void 0 : loaderConfig.projects) !== null && _a !== void 0 ? _a : [])]
141
145
  .filter((p) => p.projectApiToken)
142
- .map((p) => lang_utils_1.tuple(p.projectId, p.projectApiToken)));
146
+ .map((p) => (0, lang_utils_1.tuple)(p.projectId, p.projectApiToken)));
143
147
  // Resolve what will be synced
144
148
  const projectConfigMap = lodash_1.default.keyBy(context.config.projects, (p) => p.projectId);
145
149
  const projectWithVersion = opts.projects.map((p) => {
@@ -176,7 +180,7 @@ function sync(opts, metadataDefaults) {
176
180
  // projectApiTokens from the server (as a user that has permission to do so).
177
181
  if (projectSyncParams.some((p) => !p.projectApiToken)) {
178
182
  try {
179
- context = yield get_context_1.getContext(opts);
183
+ context = yield (0, get_context_1.getContext)(opts);
180
184
  }
181
185
  catch (e) {
182
186
  if (e.message.includes("Unable to authenticate Plasmic")) {
@@ -195,7 +199,7 @@ function sync(opts, metadataDefaults) {
195
199
  const versionResolution = yield context.api.resolveSync(projectSyncParams, true // we always want to get dependency data
196
200
  );
197
201
  // Make sure the resolution is compatible with plasmic.json and plasmic.lock
198
- const projectsToSync = yield resolve_utils_1.checkVersionResolution(versionResolution, context, opts);
202
+ const projectsToSync = yield (0, resolve_utils_1.checkVersionResolution)(versionResolution, context, opts);
199
203
  if (projectsToSync.length <= 0) {
200
204
  deps_1.logger.info("Your projects are up-to-date with respect to your specified version ranges. Nothing to sync.");
201
205
  return;
@@ -216,7 +220,7 @@ function sync(opts, metadataDefaults) {
216
220
  const externalNpmPackages = new Set();
217
221
  const externalCssImports = new Set();
218
222
  // Perform the actual sync
219
- yield file_utils_1.withBufferedFs(() => __awaiter(this, void 0, void 0, function* () {
223
+ yield (0, file_utils_1.withBufferedFs)(() => __awaiter(this, void 0, void 0, function* () {
220
224
  var _b;
221
225
  // Sync in sequence (no parallelism)
222
226
  // going in reverse to get leaves of the dependency tree first
@@ -246,7 +250,7 @@ function sync(opts, metadataDefaults) {
246
250
  });
247
251
  }
248
252
  // Now we know config.components are all correct, so we can go ahead and fix up all the import statements
249
- yield code_utils_1.fixAllImportStatements(context, opts.baseDir, summary);
253
+ yield (0, code_utils_1.fixAllImportStatements)(context, opts.baseDir, summary);
250
254
  if (process.env.PLASMIC_LOADER) {
251
255
  const rootProjectIds = new Set(projectSyncParams.map((p) => p.projectId));
252
256
  const freshIdsAndTokens = projectIdsAndTokens
@@ -262,7 +266,7 @@ function sync(opts, metadataDefaults) {
262
266
  }
263
267
  });
264
268
  // Write the new ComponentConfigs to disk
265
- yield config_utils_1.updateConfig(context, context.config, baseDir);
269
+ yield (0, config_utils_1.updateConfig)(context, context.config, baseDir);
266
270
  }));
267
271
  yield checkExternalPkgs(context, baseDir, opts, Array.from(externalNpmPackages.keys()));
268
272
  if (!opts.quiet && externalCssImports.size > 0) {
@@ -274,12 +278,12 @@ function sync(opts, metadataDefaults) {
274
278
  // Post-sync commands
275
279
  if (!opts.ignorePostSync) {
276
280
  for (const cmd of context.config.postSyncCommands || []) {
277
- child_process_1.spawnSync(cmd, { shell: true, stdio: "inherit" });
281
+ (0, child_process_1.spawnSync)(cmd, { shell: true, stdio: "inherit" });
278
282
  }
279
283
  }
280
284
  if (isFirstRun) {
281
285
  if (!process.env.QUIET) {
282
- help_1.printFirstSyncInfo(context);
286
+ (0, help_1.printFirstSyncInfo)(context);
283
287
  }
284
288
  }
285
289
  });
@@ -288,13 +292,13 @@ exports.sync = sync;
288
292
  function checkExternalPkgs(context, baseDir, opts, pkgs) {
289
293
  return __awaiter(this, void 0, void 0, function* () {
290
294
  const missingPkgs = pkgs.filter((pkg) => {
291
- const installedPkg = npm_utils_1.findInstalledVersion(context.config, baseDir, pkg);
295
+ const installedPkg = (0, npm_utils_1.findInstalledVersion)(context.config, baseDir, pkg);
292
296
  return !installedPkg;
293
297
  });
294
298
  if (missingPkgs.length > 0) {
295
- const upgrade = yield user_utils_1.confirmWithUser(`The following packages aren't installed but are required by some projects, would you like to install them? ${missingPkgs.join(", ")}`, opts.yes);
299
+ const upgrade = yield (0, user_utils_1.confirmWithUser)(`The following packages aren't installed but are required by some projects, would you like to install them? ${missingPkgs.join(", ")}`, opts.yes);
296
300
  if (upgrade) {
297
- npm_utils_1.installUpgrade(context.config, missingPkgs.join(" "), baseDir);
301
+ (0, npm_utils_1.installUpgrade)(context.config, missingPkgs.join(" "), baseDir);
298
302
  }
299
303
  }
300
304
  });
@@ -303,10 +307,10 @@ function maybeRenamePathExt(context, path, ext, opts) {
303
307
  if (!path) {
304
308
  return path;
305
309
  }
306
- const correctPath = `${file_utils_1.stripExtension(path, true)}${ext}`;
310
+ const correctPath = `${(0, file_utils_1.stripExtension)(path, true)}${ext}`;
307
311
  if (path !== correctPath) {
308
312
  try {
309
- file_utils_1.renameFile(context, path, correctPath);
313
+ (0, file_utils_1.renameFile)(context, path, correctPath);
310
314
  }
311
315
  catch (e) {
312
316
  if (!(opts === null || opts === void 0 ? void 0 : opts.continueOnFailure)) {
@@ -334,8 +338,8 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, branchName,
334
338
  return __awaiter(this, void 0, void 0, function* () {
335
339
  const existingProject = context.config.projects.find((p) => p.projectId === projectId);
336
340
  const existingCompScheme = ((existingProject === null || existingProject === void 0 ? void 0 : existingProject.components) || []).map((c) => [c.id, c.scheme]);
337
- const projectApiToken = lang_utils_1.ensure((_a = projectIdsAndTokens.find((p) => p.projectId === projectId)) === null || _a === void 0 ? void 0 : _a.projectApiToken, `Could not find the API token for project ${projectId} in list: ${JSON.stringify(projectIdsAndTokens)}`);
338
- const existingChecksums = checksum_1.getChecksums(context, opts, projectId, componentIds);
341
+ const projectApiToken = (0, lang_utils_1.ensure)((_a = projectIdsAndTokens.find((p) => p.projectId === projectId)) === null || _a === void 0 ? void 0 : _a.projectApiToken, `Could not find the API token for project ${projectId} in list: ${JSON.stringify(projectIdsAndTokens)}`);
342
+ const existingChecksums = (0, checksum_1.getChecksums)(context, opts, projectId, componentIds);
339
343
  // Server-side code-gen
340
344
  const projectBundle = yield context.api.projectComponents(projectId, branchName, {
341
345
  platform: context.config.platform,
@@ -354,32 +358,32 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, branchName,
354
358
  i18nOpts: context.config.i18n,
355
359
  checksums: existingChecksums,
356
360
  codeOpts: context.config.code,
357
- metadata: get_context_1.generateMetadata(Object.assign(Object.assign({}, metadataDefaults), { platform: context.config.platform }), opts.metadata),
361
+ metadata: (0, get_context_1.generateMetadata)(Object.assign(Object.assign({}, metadataDefaults), { platform: context.config.platform }), opts.metadata),
358
362
  indirect,
359
363
  wrapPagesWithGlobalContexts: context.config.wrapPagesWithGlobalContexts,
360
364
  });
361
365
  // Convert from TSX => JSX
362
366
  if (context.config.code.lang === "js") {
363
367
  projectBundle.components.forEach((c) => {
364
- [c.renderModuleFileName, c.renderModule] = code_utils_1.maybeConvertTsxToJsx(c.renderModuleFileName, c.renderModule, opts.baseDir);
365
- [c.skeletonModuleFileName, c.skeletonModule] = code_utils_1.maybeConvertTsxToJsx(c.skeletonModuleFileName, c.skeletonModule, opts.baseDir);
368
+ [c.renderModuleFileName, c.renderModule] = (0, code_utils_1.maybeConvertTsxToJsx)(c.renderModuleFileName, c.renderModule, opts.baseDir);
369
+ [c.skeletonModuleFileName, c.skeletonModule] = (0, code_utils_1.maybeConvertTsxToJsx)(c.skeletonModuleFileName, c.skeletonModule, opts.baseDir);
366
370
  });
367
371
  projectBundle.iconAssets.forEach((icon) => {
368
- [icon.fileName, icon.module] = code_utils_1.maybeConvertTsxToJsx(icon.fileName, icon.module, opts.baseDir);
372
+ [icon.fileName, icon.module] = (0, code_utils_1.maybeConvertTsxToJsx)(icon.fileName, icon.module, opts.baseDir);
369
373
  });
370
374
  projectBundle.globalVariants.forEach((gv) => {
371
- [gv.contextFileName, gv.contextModule] = code_utils_1.maybeConvertTsxToJsx(gv.contextFileName, gv.contextModule, opts.baseDir);
375
+ [gv.contextFileName, gv.contextModule] = (0, code_utils_1.maybeConvertTsxToJsx)(gv.contextFileName, gv.contextModule, opts.baseDir);
372
376
  });
373
377
  (projectBundle.projectConfig.jsBundleThemes || []).forEach((theme) => {
374
- [theme.themeFileName, theme.themeModule] = code_utils_1.maybeConvertTsxToJsx(theme.themeFileName, theme.themeModule, opts.baseDir);
378
+ [theme.themeFileName, theme.themeModule] = (0, code_utils_1.maybeConvertTsxToJsx)(theme.themeFileName, theme.themeModule, opts.baseDir);
375
379
  });
376
380
  }
377
- yield sync_global_variants_1.syncGlobalVariants(context, projectBundle.projectConfig, projectBundle.globalVariants, projectBundle.checksums, branchName, opts.baseDir);
381
+ yield (0, sync_global_variants_1.syncGlobalVariants)(context, projectBundle.projectConfig, projectBundle.globalVariants, projectBundle.checksums, branchName, opts.baseDir);
378
382
  yield syncProjectConfig(context, projectBundle.projectConfig, projectApiToken, branchName, projectVersion, dependencies, projectBundle.components, opts.forceOverwrite, summary, projectBundle.checksums, opts.baseDir, indirect);
379
383
  syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
380
- yield sync_styles_1.upsertStyleTokens(context, projectBundle.usedTokens, projectBundle.projectConfig.projectId);
381
- yield sync_icons_1.syncProjectIconAssets(context, projectId, branchName, projectVersion, projectBundle.iconAssets, projectBundle.checksums, opts.baseDir);
382
- yield sync_images_1.syncProjectImageAssets(context, projectId, branchName, projectVersion, projectBundle.imageAssets, projectBundle.checksums);
384
+ yield (0, sync_styles_1.upsertStyleTokens)(context, projectBundle.usedTokens, projectBundle.projectConfig.projectId);
385
+ yield (0, sync_icons_1.syncProjectIconAssets)(context, projectId, branchName, projectVersion, projectBundle.iconAssets, projectBundle.checksums, opts.baseDir);
386
+ yield (0, sync_images_1.syncProjectImageAssets)(context, projectId, branchName, projectVersion, projectBundle.imageAssets, projectBundle.checksums);
383
387
  (projectBundle.usedNpmPackages || []).forEach((pkg) => externalNpmPackages.add(pkg));
384
388
  (projectBundle.externalCssImports || []).forEach((css) => externalCssImports.add(css));
385
389
  });
@@ -389,16 +393,16 @@ function syncStyleConfig(context, response) {
389
393
  const expectedPath = context.config.style.defaultStyleCssFilePath ||
390
394
  upath_1.default.join(context.config.defaultPlasmicDir, response.defaultStyleCssFileName);
391
395
  context.config.style.defaultStyleCssFilePath = expectedPath;
392
- yield file_utils_1.writeFileContent(context, expectedPath, response.defaultStyleCssRules, {
396
+ yield (0, file_utils_1.writeFileContent)(context, expectedPath, response.defaultStyleCssRules, {
393
397
  force: true,
394
398
  });
395
399
  });
396
400
  }
397
401
  function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, summary, checksums, baseDir, indirect) {
398
402
  return __awaiter(this, void 0, void 0, function* () {
399
- const defaultCssFilePath = file_utils_1.defaultResourcePath(context, projectBundle.projectName, projectBundle.cssFileName);
403
+ const defaultCssFilePath = (0, file_utils_1.defaultResourcePath)(context, projectBundle.projectName, projectBundle.cssFileName);
400
404
  const isNew = !context.config.projects.find((p) => p.projectId === projectBundle.projectId);
401
- const projectConfig = config_utils_1.getOrAddProjectConfig(context, projectBundle.projectId, config_utils_1.createProjectConfig({
405
+ const projectConfig = (0, config_utils_1.getOrAddProjectConfig)(context, projectBundle.projectId, (0, config_utils_1.createProjectConfig)({
402
406
  projectId: projectBundle.projectId,
403
407
  projectApiToken,
404
408
  projectName: projectBundle.projectName,
@@ -412,14 +416,14 @@ function syncProjectConfig(context, projectBundle, projectApiToken, branchName,
412
416
  projectConfig.cssFilePath = defaultCssFilePath;
413
417
  }
414
418
  // plasmic.lock
415
- const projectLock = config_utils_1.getOrAddProjectLock(context, projectConfig.projectId, branchName);
419
+ const projectLock = (0, config_utils_1.getOrAddProjectLock)(context, projectConfig.projectId, branchName);
416
420
  projectLock.version = version;
417
421
  projectLock.dependencies = dependencies;
418
422
  projectLock.lang = context.config.code.lang;
419
423
  if (projectBundle.cssRules) {
420
- const formattedCssRules = code_utils_1.formatAsLocal(projectBundle.cssRules, projectConfig.cssFilePath, baseDir);
424
+ const formattedCssRules = (0, code_utils_1.formatAsLocal)(projectBundle.cssRules, projectConfig.cssFilePath, baseDir);
421
425
  // Write out project css
422
- yield file_utils_1.writeFileContent(context, projectConfig.cssFilePath, formattedCssRules, {
426
+ yield (0, file_utils_1.writeFileContent)(context, projectConfig.cssFilePath, formattedCssRules, {
423
427
  force: !isNew,
424
428
  });
425
429
  }
@@ -459,13 +463,13 @@ function syncProjectConfig(context, projectBundle, projectApiToken, branchName,
459
463
  projectConfig.jsBundleThemes.length === 0) {
460
464
  delete projectConfig.jsBundleThemes;
461
465
  }
462
- yield sync_global_contexts_1.syncGlobalContexts(context, projectBundle, projectConfig, projectLock, checksums, baseDir);
466
+ yield (0, sync_global_contexts_1.syncGlobalContexts)(context, projectBundle, projectConfig, projectLock, checksums, baseDir);
463
467
  // Write out components
464
- yield sync_components_1.syncProjectComponents(context, projectConfig, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir);
468
+ yield (0, sync_components_1.syncProjectComponents)(context, projectConfig, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir);
465
469
  });
466
470
  }
467
471
  function syncCodeComponentsMeta(context, projectId, codeComponentBundles) {
468
- const projectConfig = config_utils_1.getOrAddProjectConfig(context, projectId);
472
+ const projectConfig = (0, config_utils_1.getOrAddProjectConfig)(context, projectId);
469
473
  projectConfig.codeComponents = codeComponentBundles.map((meta) => (Object.assign({ id: meta.id, name: meta.name, displayName: meta.displayName, componentImportPath: meta.importPath }, (meta.helper
470
474
  ? {
471
475
  helper: {
@@ -18,11 +18,11 @@ const file_utils_1 = require("../utils/file-utils");
18
18
  const get_context_1 = require("../utils/get-context");
19
19
  function uploadJsBundle(opts) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- const context = yield get_context_1.getContext(opts);
21
+ const context = yield (0, get_context_1.getContext)(opts);
22
22
  const api = context.api;
23
- yield api.uploadBundle(opts.project, opts.bundleName, pako_1.default.deflate(file_utils_1.readFileText(opts.bundleJsFile), { to: "string" }), opts.cssFiles.map((f) => pako_1.default.deflate(file_utils_1.readFileText(f), { to: "string" })), pako_1.default.deflate(file_utils_1.readFileText(opts.metaJsonFile), { to: "string" }), opts.genModulePath, opts.genCssPaths, opts.pkgVersion, opts.extraPropMetaJsonFile
24
- ? file_utils_1.readFileText(opts.extraPropMetaJsonFile)
25
- : undefined, opts.themeProviderWrapper, opts.themeModuleFile ? file_utils_1.readFileText(opts.themeModuleFile) : undefined);
23
+ yield api.uploadBundle(opts.project, opts.bundleName, pako_1.default.deflate((0, file_utils_1.readFileText)(opts.bundleJsFile), { to: "string" }), opts.cssFiles.map((f) => pako_1.default.deflate((0, file_utils_1.readFileText)(f), { to: "string" })), pako_1.default.deflate((0, file_utils_1.readFileText)(opts.metaJsonFile), { to: "string" }), opts.genModulePath, opts.genCssPaths, opts.pkgVersion, opts.extraPropMetaJsonFile
24
+ ? (0, file_utils_1.readFileText)(opts.extraPropMetaJsonFile)
25
+ : undefined, opts.themeProviderWrapper, opts.themeModuleFile ? (0, file_utils_1.readFileText)(opts.themeModuleFile) : undefined);
26
26
  });
27
27
  }
28
28
  exports.uploadJsBundle = uploadJsBundle;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
18
  var __importStar = (this && this.__importStar) || function (mod) {
15
19
  if (mod && mod.__esModule) return mod;
16
20
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
22
  __setModuleDefault(result, mod);
19
23
  return result;
20
24
  };
@@ -44,8 +48,8 @@ function watchProjects(opts, metadataDefaults, onProjectUpdate) {
44
48
  // Perform a sync before watch.
45
49
  const syncOpts = Object.assign(Object.assign({}, opts), { quiet: true });
46
50
  const syncMetadata = Object.assign(Object.assign({}, metadataDefaults), { command: "watch" });
47
- yield sync_1.sync(syncOpts, syncMetadata);
48
- const context = yield get_context_1.getContext(opts);
51
+ yield (0, sync_1.sync)(syncOpts, syncMetadata);
52
+ const context = yield (0, get_context_1.getContext)(opts);
49
53
  const config = context.config;
50
54
  const socket = context.api.connectSocket();
51
55
  const projectIds = lodash_1.default.uniq(opts.projects.length > 0
@@ -78,8 +82,8 @@ function watchProjects(opts, metadataDefaults, onProjectUpdate) {
78
82
  // Just run syncProjects() for now when any project has been updated
79
83
  // Note on the 'updated to revision' part: this is parsed by the
80
84
  // loader package to know that we finished updating the components.
81
- yield sync_1.sync(syncOpts, syncMetadata);
82
- deps_1.logger.info(`[${moment_1.default().format("HH:mm:ss")}] Project ${data.projectId} updated to revision ${data.revisionNum}`);
85
+ yield (0, sync_1.sync)(syncOpts, syncMetadata);
86
+ deps_1.logger.info(`[${(0, moment_1.default)().format("HH:mm:ss")}] Project ${data.projectId} updated to revision ${data.revisionNum}`);
83
87
  onProjectUpdate === null || onProjectUpdate === void 0 ? void 0 : onProjectUpdate();
84
88
  }), true));
85
89
  });
package/dist/api.d.ts CHANGED
@@ -96,7 +96,7 @@ export interface ProjectBundle {
96
96
  usedNpmPackages: string[];
97
97
  externalCssImports: string[];
98
98
  }
99
- export declare type ProjectMeta = Omit<ProjectBundle, "projectConfig">;
99
+ export type ProjectMeta = Omit<ProjectBundle, "projectConfig">;
100
100
  export interface StyleConfigResponse {
101
101
  defaultStyleCssFileName: string;
102
102
  defaultStyleCssRules: string;
package/dist/api.js CHANGED
@@ -148,7 +148,7 @@ class PlasmicApi {
148
148
  });
149
149
  }
150
150
  connectSocket() {
151
- const socket = socket_io_client_1.default(this.studioHost, {
151
+ const socket = (0, socket_io_client_1.default)(this.studioHost, {
152
152
  path: `/api/v1/socket`,
153
153
  transportOptions: {
154
154
  polling: {
package/dist/deps.js CHANGED
@@ -16,5 +16,7 @@ exports.logger = winston_1.default.createLogger({
16
16
  ),
17
17
  stderrLevels: ["error"],
18
18
  }),
19
+ //new winston.transports.File({ filename: "error.log", level: "error" }),
20
+ //new winston.transports.File({ filename: "combined.log", level: "info" }),
19
21
  ],
20
22
  });