@plasmicapp/cli 0.1.173 → 0.1.174

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.
@@ -50,11 +50,11 @@ const resolve_utils_1 = require("../utils/resolve-utils");
50
50
  const semver = __importStar(require("../utils/semver"));
51
51
  const user_utils_1 = require("../utils/user-utils");
52
52
  const sync_components_1 = require("./sync-components");
53
+ const sync_global_contexts_1 = require("./sync-global-contexts");
53
54
  const sync_global_variants_1 = require("./sync-global-variants");
54
55
  const sync_icons_1 = require("./sync-icons");
55
56
  const sync_images_1 = require("./sync-images");
56
57
  const sync_styles_1 = require("./sync-styles");
57
- const sync_global_contexts_1 = require("./sync-global-contexts");
58
58
  function ensureRequiredPackages(context, baseDir, yes) {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
60
  const requireds = yield context.api.requiredPackages();
@@ -302,23 +302,33 @@ function checkExternalPkgs(context, baseDir, opts, pkgs) {
302
302
  }
303
303
  });
304
304
  }
305
- function maybeRenamePathExt(context, path, ext) {
305
+ function maybeRenamePathExt(context, path, ext, opts) {
306
306
  if (!path) {
307
307
  return path;
308
308
  }
309
309
  const correctPath = `${file_utils_1.stripExtension(path, true)}${ext}`;
310
310
  if (path !== correctPath) {
311
- file_utils_1.renameFile(context, path, correctPath);
311
+ try {
312
+ file_utils_1.renameFile(context, path, correctPath);
313
+ }
314
+ catch (e) {
315
+ if (!(opts === null || opts === void 0 ? void 0 : opts.continueOnFailure)) {
316
+ throw e;
317
+ }
318
+ else {
319
+ deps_1.logger.warn(e);
320
+ }
321
+ }
312
322
  }
313
323
  return correctPath;
314
324
  }
315
325
  function fixFileExtension(context) {
316
326
  const cssExt = context.config.style.scheme === "css-modules" ? ".module.css" : ".css";
317
- context.config.style.defaultStyleCssFilePath = maybeRenamePathExt(context, context.config.style.defaultStyleCssFilePath, cssExt);
327
+ context.config.style.defaultStyleCssFilePath = maybeRenamePathExt(context, context.config.style.defaultStyleCssFilePath, cssExt, { continueOnFailure: true });
318
328
  context.config.projects.forEach((project) => {
319
- project.cssFilePath = maybeRenamePathExt(context, project.cssFilePath, cssExt);
329
+ project.cssFilePath = maybeRenamePathExt(context, project.cssFilePath, cssExt, { continueOnFailure: true });
320
330
  project.components.forEach((component) => {
321
- component.cssFilePath = maybeRenamePathExt(context, component.cssFilePath, cssExt);
331
+ component.cssFilePath = maybeRenamePathExt(context, component.cssFilePath, cssExt, { continueOnFailure: true });
322
332
  });
323
333
  });
324
334
  }
@@ -104,6 +104,14 @@ function removeMissingFilesFromLock(context, config, lock) {
104
104
  return project;
105
105
  });
106
106
  }
107
+ /**
108
+ *
109
+ * @param context
110
+ * @param expectedPath
111
+ * @param baseNameToFiles
112
+ * @returns The path if we are able to find the file, undefined if we need to recreate it
113
+ * @throws if the user interrupts flow
114
+ */
107
115
  function attemptToRestoreFilePath(context, expectedPath, baseNameToFiles) {
108
116
  return __awaiter(this, void 0, void 0, function* () {
109
117
  // If the path is not set, always recreate.
@@ -163,16 +171,19 @@ function resolveMissingFilesInConfig(context, config) {
163
171
  });
164
172
  }
165
173
  context.config.globalVariants.variantGroups = yield filterFiles(context.config.globalVariants.variantGroups, "contextFilePath");
174
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
166
175
  context.config.style.defaultStyleCssFilePath =
167
- (yield attemptToRestoreFilePath(context, context.config.style.defaultStyleCssFilePath, baseNameToFiles)) || "";
176
+ (yield attemptToRestoreFilePath(context, context.config.style.defaultStyleCssFilePath, baseNameToFiles)) || context.config.style.defaultStyleCssFilePath;
177
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
168
178
  for (const project of config.projects) {
169
179
  project.cssFilePath =
170
- (yield attemptToRestoreFilePath(context, project.cssFilePath, baseNameToFiles)) || "";
180
+ (yield attemptToRestoreFilePath(context, project.cssFilePath, baseNameToFiles)) || project.cssFilePath;
171
181
  if (!project.globalContextsFilePath) {
172
182
  project.globalContextsFilePath = "";
173
183
  }
184
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
174
185
  project.globalContextsFilePath =
175
- (yield attemptToRestoreFilePath(context, project.globalContextsFilePath, baseNameToFiles)) || "";
186
+ (yield attemptToRestoreFilePath(context, project.globalContextsFilePath, baseNameToFiles)) || project.globalContextsFilePath;
176
187
  project.images = yield filterFiles(project.images, "filePath");
177
188
  project.icons = yield filterFiles(project.icons, "moduleFilePath");
178
189
  project.jsBundleThemes = yield filterFiles(project.jsBundleThemes || [], "themeFilePath");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.173",
3
+ "version": "0.1.174",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -60,11 +60,11 @@ import {
60
60
  ComponentPendingMerge,
61
61
  syncProjectComponents,
62
62
  } from "./sync-components";
63
+ import { syncGlobalContexts } from "./sync-global-contexts";
63
64
  import { syncGlobalVariants } from "./sync-global-variants";
64
65
  import { syncProjectIconAssets } from "./sync-icons";
65
66
  import { syncProjectImageAssets } from "./sync-images";
66
67
  import { upsertStyleTokens } from "./sync-styles";
67
- import { syncGlobalContexts } from "./sync-global-contexts";
68
68
 
69
69
  export interface SyncArgs extends CommonArgs {
70
70
  projects: readonly string[];
@@ -488,14 +488,25 @@ async function checkExternalPkgs(
488
488
  function maybeRenamePathExt(
489
489
  context: PlasmicContext,
490
490
  path: string,
491
- ext: string
491
+ ext: string,
492
+ opts?: {
493
+ continueOnFailure?: boolean;
494
+ }
492
495
  ) {
493
496
  if (!path) {
494
497
  return path;
495
498
  }
496
499
  const correctPath = `${stripExtension(path, true)}${ext}`;
497
500
  if (path !== correctPath) {
498
- renameFile(context, path, correctPath);
501
+ try {
502
+ renameFile(context, path, correctPath);
503
+ } catch (e) {
504
+ if (!opts?.continueOnFailure) {
505
+ throw e;
506
+ } else {
507
+ logger.warn(e);
508
+ }
509
+ }
499
510
  }
500
511
  return correctPath;
501
512
  }
@@ -506,19 +517,22 @@ function fixFileExtension(context: PlasmicContext) {
506
517
  context.config.style.defaultStyleCssFilePath = maybeRenamePathExt(
507
518
  context,
508
519
  context.config.style.defaultStyleCssFilePath,
509
- cssExt
520
+ cssExt,
521
+ { continueOnFailure: true }
510
522
  );
511
523
  context.config.projects.forEach((project) => {
512
524
  project.cssFilePath = maybeRenamePathExt(
513
525
  context,
514
526
  project.cssFilePath,
515
- cssExt
527
+ cssExt,
528
+ { continueOnFailure: true }
516
529
  );
517
530
  project.components.forEach((component) => {
518
531
  component.cssFilePath = maybeRenamePathExt(
519
532
  context,
520
533
  component.cssFilePath,
521
- cssExt
534
+ cssExt,
535
+ { continueOnFailure: true }
522
536
  );
523
537
  });
524
538
  });
@@ -106,6 +106,14 @@ function removeMissingFilesFromLock(
106
106
  });
107
107
  }
108
108
 
109
+ /**
110
+ *
111
+ * @param context
112
+ * @param expectedPath
113
+ * @param baseNameToFiles
114
+ * @returns The path if we are able to find the file, undefined if we need to recreate it
115
+ * @throws if the user interrupts flow
116
+ */
109
117
  async function attemptToRestoreFilePath(
110
118
  context: PlasmicContext,
111
119
  expectedPath: string,
@@ -193,30 +201,34 @@ async function resolveMissingFilesInConfig(
193
201
  "contextFilePath"
194
202
  );
195
203
 
204
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
196
205
  context.config.style.defaultStyleCssFilePath =
197
206
  (await attemptToRestoreFilePath(
198
207
  context,
199
208
  context.config.style.defaultStyleCssFilePath,
200
209
  baseNameToFiles
201
- )) || "";
210
+ )) || context.config.style.defaultStyleCssFilePath;
202
211
 
212
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
203
213
  for (const project of config.projects) {
204
214
  project.cssFilePath =
205
215
  (await attemptToRestoreFilePath(
206
216
  context,
207
217
  project.cssFilePath,
208
218
  baseNameToFiles
209
- )) || "";
219
+ )) || project.cssFilePath;
210
220
 
211
221
  if (!project.globalContextsFilePath) {
212
222
  project.globalContextsFilePath = "";
213
223
  }
224
+
225
+ // Try to find the file, otherwise recreate at either the specified path or default path (if both are falsey)
214
226
  project.globalContextsFilePath =
215
227
  (await attemptToRestoreFilePath(
216
228
  context,
217
229
  project.globalContextsFilePath,
218
230
  baseNameToFiles
219
- )) || "";
231
+ )) || project.globalContextsFilePath;
220
232
 
221
233
  project.images = await filterFiles(project.images, "filePath");
222
234
  project.icons = await filterFiles(project.icons, "moduleFilePath");
@@ -1,2 +0,0 @@
1
- import { PlasmicConfig } from "../utils/config-utils";
2
- export declare function ensureImportModuleType(config: PlasmicConfig): PlasmicConfig;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureImportModuleType = void 0;
4
- function ensureImportModuleType(config) {
5
- for (const project of config.projects) {
6
- for (const component of project.components) {
7
- component.importSpec.moduleType = "local";
8
- }
9
- }
10
- return config;
11
- }
12
- exports.ensureImportModuleType = ensureImportModuleType;