@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.
@@ -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>;
@@ -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
  }
@@ -32,6 +32,7 @@ exports.defaultPlasmicJson = {
32
32
  globalVariants: {
33
33
  variantGroups: [],
34
34
  },
35
+ wrapPagesWithGlobalContexts: true,
35
36
  cliVersion: "0.1.44",
36
37
  };
37
38
  function standardTestSetup(includeDep = true) {
@@ -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 */
@@ -70,6 +70,7 @@ exports.DEFAULT_CONFIG = {
70
70
  globalVariants: {
71
71
  variantGroups: [],
72
72
  },
73
+ wrapPagesWithGlobalContexts: true,
73
74
  };
74
75
  exports.DEFAULT_PUBLIC_FILES_CONFIG = {
75
76
  scheme: "public-files",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.174",
3
+ "version": "0.1.175",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -595,6 +595,7 @@ async function syncProject(
595
595
  opts.metadata
596
596
  ),
597
597
  indirect,
598
+ wrapPagesWithGlobalContexts: context.config.wrapPagesWithGlobalContexts,
598
599
  });
599
600
 
600
601
  // Convert from TSX => JSX
package/src/api.ts CHANGED
@@ -266,6 +266,7 @@ export class PlasmicApi {
266
266
  codeOpts: CodeConfig;
267
267
  checksums: ChecksumBundle;
268
268
  indirect: boolean;
269
+ wrapPagesWithGlobalContexts: boolean;
269
270
  metadata?: Metadata;
270
271
  }
271
272
  ): Promise<ProjectBundle> {
@@ -34,6 +34,7 @@ export const defaultPlasmicJson: PlasmicConfig = {
34
34
  globalVariants: {
35
35
  variantGroups: [],
36
36
  },
37
+ wrapPagesWithGlobalContexts: true,
37
38
  cliVersion: "0.1.44",
38
39
  };
39
40
  export function standardTestSetup(includeDep = true) {
@@ -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 = {