@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.
- package/dist/actions/sync.js +8 -5
- package/dist/api.d.ts +4 -0
- package/dist/plasmic.schema.json +15 -0
- package/dist/utils/code-utils.js +18 -1
- package/dist/utils/config-utils.d.ts +4 -0
- package/package.json +3 -3
- package/src/actions/sync.ts +8 -0
- package/src/api.ts +4 -0
- package/src/utils/code-utils.ts +18 -0
- package/src/utils/config-utils.ts +4 -0
package/dist/actions/sync.js
CHANGED
|
@@ -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
|
-
|
|
471
|
-
|
|
472
|
-
|
|
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
package/dist/plasmic.schema.json
CHANGED
|
@@ -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
|
},
|
package/dist/utils/code-utils.js
CHANGED
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
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": "
|
|
84
|
+
"gitHead": "0edb216f831947b2f9d02daf62262258f2c2c68c"
|
|
85
85
|
}
|
package/src/actions/sync.ts
CHANGED
|
@@ -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
package/src/utils/code-utils.ts
CHANGED
|
@@ -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) {
|