@plasmicapp/cli 0.1.253 → 0.1.255

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.
@@ -466,9 +466,12 @@ function syncProjectConfig(context, projectBundle, projectApiToken, branchName,
466
466
  }
467
467
  function syncCodeComponentsMeta(context, projectId, codeComponentBundles) {
468
468
  const projectConfig = config_utils_1.getOrAddProjectConfig(context, projectId);
469
- projectConfig.codeComponents = codeComponentBundles.map((meta) => ({
470
- id: meta.id,
471
- name: meta.name,
472
- componentImportPath: meta.importPath,
473
- }));
469
+ projectConfig.codeComponents = codeComponentBundles.map((meta) => (Object.assign({ id: meta.id, name: meta.name, componentImportPath: meta.importPath }, (meta.helper
470
+ ? {
471
+ helper: {
472
+ name: meta.helper.name,
473
+ importPath: meta.helper.importPath,
474
+ },
475
+ }
476
+ : {}))));
474
477
  }
package/dist/api.d.ts CHANGED
@@ -130,6 +130,10 @@ export interface CodeComponentMeta {
130
130
  id: string;
131
131
  name: string;
132
132
  importPath: string;
133
+ helper?: {
134
+ name: string;
135
+ importPath: string;
136
+ };
133
137
  }
134
138
  export interface ProjectIconsResponse {
135
139
  version: string;
@@ -6,6 +6,21 @@
6
6
  "componentImportPath": {
7
7
  "type": "string"
8
8
  },
9
+ "helper": {
10
+ "properties": {
11
+ "importPath": {
12
+ "type": "string"
13
+ },
14
+ "name": {
15
+ "type": "string"
16
+ }
17
+ },
18
+ "required": [
19
+ "importPath",
20
+ "name"
21
+ ],
22
+ "type": "object"
23
+ },
9
24
  "id": {
10
25
  "type": "string"
11
26
  },
@@ -158,7 +158,7 @@ function replaceImports(context, code, fromPath, fixImportContext, removeImportD
158
158
  });
159
159
  const commentsToRemove = new Set();
160
160
  file.program.body.forEach((stmt) => {
161
- var _a;
161
+ var _a, _b;
162
162
  if (stmt.type !== "ImportDeclaration") {
163
163
  return;
164
164
  }
@@ -265,6 +265,23 @@ function replaceImports(context, code, fromPath, fixImportContext, removeImportD
265
265
  stmt.source.value = meta.componentImportPath;
266
266
  }
267
267
  }
268
+ else if (type === "codeComponentHelper") {
269
+ const meta = fixImportContext.codeComponentMetas[uuid];
270
+ if (!((_b = meta.helper) === null || _b === void 0 ? void 0 : _b.importPath)) {
271
+ throw new error_1.HandledError(`Encountered code component "${meta.name}" that was not registered with an importPath to the component helper, so we don't know where to import this code component helper from. Please see https://docs.plasmic.app/learn/code-components-ref/`);
272
+ }
273
+ if (meta.helper.importPath[0] === ".") {
274
+ // Relative path from the project root
275
+ const toPath = upath_1.default.join(context.rootDir, meta.helper.importPath);
276
+ lang_utils_1.assert(upath_1.default.isAbsolute(toPath));
277
+ const realPath = makeImportPath(context, fromPath, toPath, true, true);
278
+ stmt.source.value = realPath;
279
+ }
280
+ else {
281
+ // npm package
282
+ stmt.source.value = meta.helper.importPath;
283
+ }
284
+ }
268
285
  else if (type === "globalContext") {
269
286
  const projectConfig = fixImportContext.projects[uuid];
270
287
  if (!projectConfig) {
@@ -112,6 +112,10 @@ export interface CodeComponentConfig {
112
112
  id: string;
113
113
  name: string;
114
114
  componentImportPath: string;
115
+ helper?: {
116
+ name: string;
117
+ importPath: string;
118
+ };
115
119
  }
116
120
  export interface ProjectConfig {
117
121
  /** Project ID */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.253",
3
+ "version": "0.1.255",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@babel/preset-typescript": "^7.12.1",
23
- "@plasmicapp/react-web": "0.2.190",
23
+ "@plasmicapp/react-web": "0.2.191",
24
24
  "@types/cli-progress": "^3.11.0",
25
25
  "@types/findup-sync": "^2.0.2",
26
26
  "@types/glob": "^7.1.3",
@@ -81,5 +81,5 @@
81
81
  "wrap-ansi": "^7.0.0",
82
82
  "yargs": "^15.4.1"
83
83
  },
84
- "gitHead": "96b7db457fb8ad72167bc8a793d2718406d763a5"
84
+ "gitHead": "0edb216f831947b2f9d02daf62262258f2c2c68c"
85
85
  }
@@ -836,5 +836,13 @@ function syncCodeComponentsMeta(
836
836
  id: meta.id,
837
837
  name: meta.name,
838
838
  componentImportPath: meta.importPath,
839
+ ...(meta.helper
840
+ ? {
841
+ helper: {
842
+ name: meta.helper.name,
843
+ importPath: meta.helper.importPath,
844
+ },
845
+ }
846
+ : {}),
839
847
  }));
840
848
  }
package/src/api.ts CHANGED
@@ -166,6 +166,10 @@ export interface CodeComponentMeta {
166
166
  id: string; // component uuid
167
167
  name: string;
168
168
  importPath: string;
169
+ helper?: {
170
+ name: string;
171
+ importPath: string;
172
+ }
169
173
  }
170
174
 
171
175
  export interface ProjectIconsResponse {
@@ -156,6 +156,7 @@ type PlasmicImportType =
156
156
  | "picture"
157
157
  | "jsBundle"
158
158
  | "codeComponent"
159
+ | "codeComponentHelper"
159
160
  | "globalContext"
160
161
  | undefined;
161
162
 
@@ -343,6 +344,23 @@ export function replaceImports(
343
344
  // npm package
344
345
  stmt.source.value = meta.componentImportPath;
345
346
  }
347
+ } else if (type === "codeComponentHelper") {
348
+ const meta = fixImportContext.codeComponentMetas[uuid];
349
+ if (!meta.helper?.importPath) {
350
+ throw new HandledError(
351
+ `Encountered code component "${meta.name}" that was not registered with an importPath to the component helper, so we don't know where to import this code component helper from. Please see https://docs.plasmic.app/learn/code-components-ref/`
352
+ );
353
+ }
354
+ if (meta.helper.importPath[0] === ".") {
355
+ // Relative path from the project root
356
+ const toPath = path.join(context.rootDir, meta.helper.importPath);
357
+ assert(path.isAbsolute(toPath));
358
+ const realPath = makeImportPath(context, fromPath, toPath, true, true);
359
+ stmt.source.value = realPath;
360
+ } else {
361
+ // npm package
362
+ stmt.source.value = meta.helper.importPath;
363
+ }
346
364
  } else if (type === "globalContext") {
347
365
  const projectConfig = fixImportContext.projects[uuid];
348
366
  if (!projectConfig) {
@@ -156,6 +156,10 @@ export interface CodeComponentConfig {
156
156
  id: string;
157
157
  name: string;
158
158
  componentImportPath: string;
159
+ helper?: {
160
+ name: string;
161
+ importPath: string;
162
+ }
159
163
  }
160
164
 
161
165
  export interface ProjectConfig {