@plasmicapp/cli 0.1.183 → 0.1.184

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.
@@ -42,7 +42,8 @@ const updateDirectSkeleton = (newFileContent, editedFileContent, context, compCo
42
42
  throw e;
43
43
  }
44
44
  else {
45
- throw new error_1.HandledError(e.messag);
45
+ lang_utils_1.assert(e instanceof Error);
46
+ throw new error_1.HandledError(e.message);
46
47
  }
47
48
  }
48
49
  })), () => { }, appendJsxOnMissingBase);
@@ -170,7 +171,7 @@ function syncProjectComponents(context, project, version, componentBundles, forc
170
171
  }
171
172
  if (isPage &&
172
173
  config_utils_1.isPageAwarePlatform(context.config.platform) &&
173
- skeletonPath !== compConfig.importSpec.modulePath &&
174
+ !file_utils_1.eqPagePath(skeletonPath, compConfig.importSpec.modulePath) &&
174
175
  file_utils_1.fileExists(context, compConfig.importSpec.modulePath)) {
175
176
  if (context.cliArgs.quiet !== true) {
176
177
  deps_1.logger.info(`Renaming page file: ${compConfig.importSpec.modulePath} -> ${skeletonPath}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`);
package/dist/index.js CHANGED
File without changes
@@ -9,6 +9,16 @@ export declare function writeFileContentRaw(filePath: string, content: string |
9
9
  export declare function defaultResourcePath(context: PlasmicContext, project: ProjectConfig | ProjectMetaBundle | string, ...subpaths: string[]): string;
10
10
  export declare function defaultPublicResourcePath(context: PlasmicContext, project: ProjectConfig, ...subpaths: string[]): string;
11
11
  export declare function defaultPagePath(context: PlasmicContext, fileName: string): string;
12
+ /**
13
+ * Returns true iff paths `a` and `b` resolve to the same page URI. For
14
+ * example:
15
+ *
16
+ * - pages/about.tsx and pages/about.js resolve to the same URI (/about).
17
+ * - pages/about/index.tsx and pages/about.tsx resolve to the same URI (/about).
18
+ * - pages/index.tsx and pages/index/index.tsx do not resolve to the same URI
19
+ * (they resolve, respectively, to / and /index).
20
+ */
21
+ export declare function eqPagePath(a: string, b: string): boolean;
12
22
  export declare function writeFileContent(context: PlasmicContext, srcDirFilePath: string, content: string | Buffer, opts?: {
13
23
  force?: boolean;
14
24
  }): Promise<void>;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.existsBuffered = exports.deleteFileBuffered = exports.renameFileBuffered = exports.readFileText = exports.writeFileText = exports.withBufferedFs = exports.assertAllPathsInRootDir = exports.findFile = exports.findSrcDirPath = exports.buildBaseNameToFiles = exports.renameFile = exports.makeFilePath = exports.fileExists = exports.deleteFile = exports.readFileContent = exports.writeFileContent = exports.defaultPagePath = exports.defaultPublicResourcePath = exports.defaultResourcePath = exports.writeFileContentRaw = exports.stripExtension = void 0;
15
+ exports.existsBuffered = exports.deleteFileBuffered = exports.renameFileBuffered = exports.readFileText = exports.writeFileText = exports.withBufferedFs = exports.assertAllPathsInRootDir = exports.findFile = exports.findSrcDirPath = exports.buildBaseNameToFiles = exports.renameFile = exports.makeFilePath = exports.fileExists = exports.deleteFile = exports.readFileContent = exports.writeFileContent = exports.eqPagePath = exports.defaultPagePath = exports.defaultPublicResourcePath = exports.defaultResourcePath = exports.writeFileContentRaw = exports.stripExtension = void 0;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const glob_1 = __importDefault(require("glob"));
18
18
  const lodash_1 = __importDefault(require("lodash"));
@@ -68,6 +68,34 @@ function defaultPagePath(context, fileName) {
68
68
  return fileName;
69
69
  }
70
70
  exports.defaultPagePath = defaultPagePath;
71
+ /**
72
+ * Returns true iff paths `a` and `b` resolve to the same page URI. For
73
+ * example:
74
+ *
75
+ * - pages/about.tsx and pages/about.js resolve to the same URI (/about).
76
+ * - pages/about/index.tsx and pages/about.tsx resolve to the same URI (/about).
77
+ * - pages/index.tsx and pages/index/index.tsx do not resolve to the same URI
78
+ * (they resolve, respectively, to / and /index).
79
+ */
80
+ function eqPagePath(a, b) {
81
+ // Remove extension and ensure that a.length < b.length.
82
+ a = stripExtension(a);
83
+ b = stripExtension(b);
84
+ if (a.length > b.length) {
85
+ [a, b] = [b, a];
86
+ }
87
+ // pages/about.tsx and pages/about.js resolve to the same page URI.
88
+ if (a === b) {
89
+ return true;
90
+ }
91
+ // pages/about.* and pages/about/index.* resolve to the same URI, but
92
+ // pages/index.* and pages/index/index.* do not.
93
+ if (!a.endsWith("/index") && `${a}/index` === b) {
94
+ return true;
95
+ }
96
+ return false;
97
+ }
98
+ exports.eqPagePath = eqPagePath;
71
99
  function writeFileContent(context, srcDirFilePath, content, opts = {}) {
72
100
  return __awaiter(this, void 0, void 0, function* () {
73
101
  const path = makeFilePath(context, srcDirFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.183",
3
+ "version": "0.1.184",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -21,6 +21,7 @@ import {
21
21
  defaultPagePath,
22
22
  defaultResourcePath,
23
23
  deleteFile,
24
+ eqPagePath,
24
25
  fileExists,
25
26
  readFileContent,
26
27
  renameFile,
@@ -71,7 +72,8 @@ const updateDirectSkeleton = async (
71
72
  ) {
72
73
  throw e;
73
74
  } else {
74
- throw new HandledError(e.messag);
75
+ assert(e instanceof Error);
76
+ throw new HandledError(e.message);
75
77
  }
76
78
  }
77
79
  }),
@@ -302,7 +304,7 @@ export async function syncProjectComponents(
302
304
  if (
303
305
  isPage &&
304
306
  isPageAwarePlatform(context.config.platform) &&
305
- skeletonPath !== compConfig.importSpec.modulePath &&
307
+ !eqPagePath(skeletonPath, compConfig.importSpec.modulePath) &&
306
308
  fileExists(context, compConfig.importSpec.modulePath)
307
309
  ) {
308
310
  if (context.cliArgs.quiet !== true) {
@@ -87,6 +87,37 @@ export function defaultPagePath(context: PlasmicContext, fileName: string) {
87
87
  return fileName;
88
88
  }
89
89
 
90
+ /**
91
+ * Returns true iff paths `a` and `b` resolve to the same page URI. For
92
+ * example:
93
+ *
94
+ * - pages/about.tsx and pages/about.js resolve to the same URI (/about).
95
+ * - pages/about/index.tsx and pages/about.tsx resolve to the same URI (/about).
96
+ * - pages/index.tsx and pages/index/index.tsx do not resolve to the same URI
97
+ * (they resolve, respectively, to / and /index).
98
+ */
99
+ export function eqPagePath(a: string, b: string) {
100
+ // Remove extension and ensure that a.length < b.length.
101
+ a = stripExtension(a);
102
+ b = stripExtension(b);
103
+ if (a.length > b.length) {
104
+ [a, b] = [b, a];
105
+ }
106
+
107
+ // pages/about.tsx and pages/about.js resolve to the same page URI.
108
+ if (a === b) {
109
+ return true;
110
+ }
111
+
112
+ // pages/about.* and pages/about/index.* resolve to the same URI, but
113
+ // pages/index.* and pages/index/index.* do not.
114
+ if (!a.endsWith("/index") && `${a}/index` === b) {
115
+ return true;
116
+ }
117
+
118
+ return false;
119
+ }
120
+
90
121
  export async function writeFileContent(
91
122
  context: PlasmicContext,
92
123
  srcDirFilePath: string,