@plasmicapp/cli 0.1.174 → 0.1.175
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 +1 -0
- package/dist/api.d.ts +1 -0
- package/dist/plasmic.schema.json +6 -1
- package/dist/test-common/fixtures.js +1 -0
- package/dist/utils/code-utils.js +9 -1
- package/dist/utils/config-utils.d.ts +2 -0
- package/dist/utils/config-utils.js +1 -0
- package/package.json +1 -1
- package/src/actions/sync.ts +1 -0
- package/src/api.ts +1 -0
- package/src/test-common/fixtures.ts +1 -0
- package/src/utils/code-utils.ts +14 -1
- package/src/utils/config-utils.ts +4 -0
package/dist/actions/sync.js
CHANGED
|
@@ -353,6 +353,7 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, componentIds
|
|
|
353
353
|
codeOpts: context.config.code,
|
|
354
354
|
metadata: get_context_1.generateMetadata(Object.assign(Object.assign({}, metadataDefaults), { platform: context.config.platform }), opts.metadata),
|
|
355
355
|
indirect,
|
|
356
|
+
wrapPagesWithGlobalContexts: context.config.wrapPagesWithGlobalContexts,
|
|
356
357
|
});
|
|
357
358
|
// Convert from TSX => JSX
|
|
358
359
|
if (context.config.code.lang === "js") {
|
package/dist/api.d.ts
CHANGED
|
@@ -184,6 +184,7 @@ export declare class PlasmicApi {
|
|
|
184
184
|
codeOpts: CodeConfig;
|
|
185
185
|
checksums: ChecksumBundle;
|
|
186
186
|
indirect: boolean;
|
|
187
|
+
wrapPagesWithGlobalContexts: boolean;
|
|
187
188
|
metadata?: Metadata;
|
|
188
189
|
}): Promise<ProjectBundle>;
|
|
189
190
|
projectMeta(projectId: string): Promise<ProjectMetaInfo>;
|
package/dist/plasmic.schema.json
CHANGED
|
@@ -458,6 +458,10 @@
|
|
|
458
458
|
"tokens": {
|
|
459
459
|
"$ref": "#/definitions/TokensConfig",
|
|
460
460
|
"description": "Config for style tokens"
|
|
461
|
+
},
|
|
462
|
+
"wrapPagesWithGlobalContexts": {
|
|
463
|
+
"description": "Wether we should wrap the pages with the project global contexts or not",
|
|
464
|
+
"type": "boolean"
|
|
461
465
|
}
|
|
462
466
|
},
|
|
463
467
|
"required": [
|
|
@@ -469,7 +473,8 @@
|
|
|
469
473
|
"projects",
|
|
470
474
|
"srcDir",
|
|
471
475
|
"style",
|
|
472
|
-
"tokens"
|
|
476
|
+
"tokens",
|
|
477
|
+
"wrapPagesWithGlobalContexts"
|
|
473
478
|
],
|
|
474
479
|
"type": "object"
|
|
475
480
|
}
|
package/dist/utils/code-utils.js
CHANGED
|
@@ -125,7 +125,7 @@ function tryParsePlasmicImportSpec(node) {
|
|
|
125
125
|
if (!c) {
|
|
126
126
|
return undefined;
|
|
127
127
|
}
|
|
128
|
-
const m = c.value.match(/plasmic-import:\s+([\w-]+)(?:\/(component|css|render|globalVariant|projectcss|defaultcss|icon|picture|jsBundle|codeComponent))?/);
|
|
128
|
+
const m = c.value.match(/plasmic-import:\s+([\w-]+)(?:\/(component|css|render|globalVariant|projectcss|defaultcss|icon|picture|jsBundle|codeComponent|globalContext))?/);
|
|
129
129
|
if (m) {
|
|
130
130
|
return { id: m[1], type: m[2] };
|
|
131
131
|
}
|
|
@@ -262,6 +262,14 @@ function replaceImports(context, code, fromPath, fixImportContext, removeImportD
|
|
|
262
262
|
stmt.source.value = meta.componentImportPath;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
+
else if (type === "globalContext") {
|
|
266
|
+
const projectConfig = fixImportContext.projects[uuid];
|
|
267
|
+
if (!projectConfig) {
|
|
268
|
+
throwMissingReference(context, "project", uuid, fromPath);
|
|
269
|
+
}
|
|
270
|
+
const realPath = makeImportPath(context, fromPath, projectConfig.globalContextsFilePath, true);
|
|
271
|
+
stmt.source.value = realPath;
|
|
272
|
+
}
|
|
265
273
|
});
|
|
266
274
|
if (!changed) {
|
|
267
275
|
return code;
|
|
@@ -56,6 +56,8 @@ export interface PlasmicConfig {
|
|
|
56
56
|
globalVariants: GlobalVariantsConfig;
|
|
57
57
|
/** Metadata for each project that has been synced */
|
|
58
58
|
projects: ProjectConfig[];
|
|
59
|
+
/** Wether we should wrap the pages with the project global contexts or not */
|
|
60
|
+
wrapPagesWithGlobalContexts: boolean;
|
|
59
61
|
/** The version of cli when this file was written */
|
|
60
62
|
cliVersion?: string;
|
|
61
63
|
/** Arbitrary command to run after `plasmic sync` has run; useful for linting and code formatting synced files */
|
package/package.json
CHANGED
package/src/actions/sync.ts
CHANGED
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
|
+
| "globalContext"
|
|
159
160
|
| undefined;
|
|
160
161
|
|
|
161
162
|
function tryParsePlasmicImportSpec(node: ImportDeclaration) {
|
|
@@ -164,7 +165,7 @@ function tryParsePlasmicImportSpec(node: ImportDeclaration) {
|
|
|
164
165
|
return undefined;
|
|
165
166
|
}
|
|
166
167
|
const m = c.value.match(
|
|
167
|
-
/plasmic-import:\s+([\w-]+)(?:\/(component|css|render|globalVariant|projectcss|defaultcss|icon|picture|jsBundle|codeComponent))?/
|
|
168
|
+
/plasmic-import:\s+([\w-]+)(?:\/(component|css|render|globalVariant|projectcss|defaultcss|icon|picture|jsBundle|codeComponent|globalContext))?/
|
|
168
169
|
);
|
|
169
170
|
if (m) {
|
|
170
171
|
return { id: m[1], type: m[2] as PlasmicImportType } as PlasmicImportSpec;
|
|
@@ -337,6 +338,18 @@ export function replaceImports(
|
|
|
337
338
|
// npm package
|
|
338
339
|
stmt.source.value = meta.componentImportPath;
|
|
339
340
|
}
|
|
341
|
+
} else if (type === "globalContext") {
|
|
342
|
+
const projectConfig = fixImportContext.projects[uuid];
|
|
343
|
+
if (!projectConfig) {
|
|
344
|
+
throwMissingReference(context, "project", uuid, fromPath);
|
|
345
|
+
}
|
|
346
|
+
const realPath = makeImportPath(
|
|
347
|
+
context,
|
|
348
|
+
fromPath,
|
|
349
|
+
projectConfig.globalContextsFilePath,
|
|
350
|
+
true
|
|
351
|
+
);
|
|
352
|
+
stmt.source.value = realPath;
|
|
340
353
|
}
|
|
341
354
|
});
|
|
342
355
|
|
|
@@ -85,6 +85,9 @@ export interface PlasmicConfig {
|
|
|
85
85
|
/** Metadata for each project that has been synced */
|
|
86
86
|
projects: ProjectConfig[];
|
|
87
87
|
|
|
88
|
+
/** Wether we should wrap the pages with the project global contexts or not */
|
|
89
|
+
wrapPagesWithGlobalContexts: boolean;
|
|
90
|
+
|
|
88
91
|
/** The version of cli when this file was written */
|
|
89
92
|
cliVersion?: string;
|
|
90
93
|
|
|
@@ -411,6 +414,7 @@ export const DEFAULT_CONFIG: PlasmicConfig = {
|
|
|
411
414
|
globalVariants: {
|
|
412
415
|
variantGroups: [],
|
|
413
416
|
},
|
|
417
|
+
wrapPagesWithGlobalContexts: true,
|
|
414
418
|
};
|
|
415
419
|
|
|
416
420
|
export const DEFAULT_PUBLIC_FILES_CONFIG: ImagesConfig = {
|