@plasmicapp/cli 0.1.160 → 0.1.164

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.
@@ -319,8 +319,8 @@ function syncProject(context, opts, projectIdsAndTokens, projectId, componentIds
319
319
  });
320
320
  }
321
321
  yield sync_global_variants_1.syncGlobalVariants(context, projectBundle.projectConfig, projectBundle.globalVariants, projectBundle.checksums, opts.baseDir);
322
- syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
323
322
  yield syncProjectConfig(context, projectBundle.projectConfig, projectApiToken, projectVersion, dependencies, projectBundle.components, opts.forceOverwrite, !!opts.appendJsxOnMissingBase, summary, pendingMerge, projectBundle.checksums, opts.baseDir);
323
+ syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
324
324
  yield sync_styles_1.upsertStyleTokens(context, projectBundle.usedTokens);
325
325
  yield sync_icons_1.syncProjectIconAssets(context, projectId, projectVersion, projectBundle.iconAssets, projectBundle.checksums, opts.baseDir);
326
326
  yield sync_images_1.syncProjectImageAssets(context, projectId, projectVersion, projectBundle.imageAssets, projectBundle.checksums);
@@ -340,13 +340,11 @@ function syncProjectConfig(context, projectBundle, projectApiToken, version, dep
340
340
  return __awaiter(this, void 0, void 0, function* () {
341
341
  const defaultCssFilePath = file_utils_1.defaultResourcePath(context, projectBundle.projectName, projectBundle.cssFileName);
342
342
  const isNew = !context.config.projects.find((p) => p.projectId === projectBundle.projectId);
343
- // If latest, use that as the range, otherwise set to latest published (>=0.0.0)
344
- const versionRange = semver.isLatest(version) ? version : ">=0.0.0";
345
343
  const projectConfig = config_utils_1.getOrAddProjectConfig(context, projectBundle.projectId, config_utils_1.createProjectConfig({
346
344
  projectId: projectBundle.projectId,
347
345
  projectApiToken,
348
346
  projectName: projectBundle.projectName,
349
- version: versionRange,
347
+ version,
350
348
  cssFilePath: defaultCssFilePath,
351
349
  }));
352
350
  // Update missing/outdated props
package/dist/api.js CHANGED
@@ -192,7 +192,7 @@ class PlasmicApi {
192
192
  }
193
193
  get codegenHost() {
194
194
  if (!this.auth.host || this.auth.host === config_utils_1.DEFAULT_HOST) {
195
- return this.auth.host;
195
+ return "https://codegen.plasmic.app";
196
196
  }
197
197
  else {
198
198
  return this.auth.host;
@@ -216,8 +216,9 @@
216
216
  "type": "string"
217
217
  },
218
218
  "scheme": {
219
- "description": "How image files should be referenced from generated React components. The choices are:\n* \"files\" - imported as relative files, like \"import img from './image.png'\". Not all bundlers support this.\n* \"public-files\" - images are stored in a public folder, and referenced from some url prefix, like `<img src=\"/static/image.png\"/>`.\n* \"inlined\" - inlined directly into React files and css files as base64-encoded data-URIs.",
219
+ "description": "How image files should be referenced from generated React components. The choices are:\n* \"files\" - imported as relative files, like \"import img from './image.png'\". Not all bundlers support this.\n* \"public-files\" - images are stored in a public folder, and referenced from some url prefix, like `<img src=\"/static/image.png\"/>`.\n* \"inlined\" - inlined directly into React files and css files as base64-encoded data-URIs.\n* \"cdn\" - images are served from Plasmic's CDN. Allows for dynamic resizing of images for\n serving the optimal file size given browser viewport.",
220
220
  "enum": [
221
+ "cdn",
221
222
  "files",
222
223
  "inlined",
223
224
  "public-files"
@@ -352,7 +352,7 @@ function fixComponentImportStatements(context, compConfig, fixImportContext, fix
352
352
  yield fixFileImportStatements(context, compConfig.importSpec.modulePath, fixImportContext, true, baseDir);
353
353
  }
354
354
  let renderModuleChanged = false;
355
- if (context.config.images.scheme !== "inlined") {
355
+ if (["files", "public-files"].includes(context.config.images.scheme)) {
356
356
  yield sync_images_1.fixComponentCssReferences(context, fixImportContext, compConfig.cssFilePath);
357
357
  if (context.config.images.scheme === "public-files") {
358
358
  renderModuleChanged = yield sync_images_1.fixComponentImagesReferences(context, fixImportContext, compConfig.renderModuleFilePath);
@@ -80,8 +80,10 @@ export interface ImagesConfig {
80
80
  * * "files" - imported as relative files, like "import img from './image.png'". Not all bundlers support this.
81
81
  * * "public-files" - images are stored in a public folder, and referenced from some url prefix, like `<img src="/static/image.png"/>`.
82
82
  * * "inlined" - inlined directly into React files and css files as base64-encoded data-URIs.
83
+ * * "cdn" - images are served from Plasmic's CDN. Allows for dynamic resizing of images for
84
+ * serving the optimal file size given browser viewport.
83
85
  */
84
- scheme: "inlined" | "files" | "public-files";
86
+ scheme: "inlined" | "files" | "public-files" | "cdn";
85
87
  /**
86
88
  * The folder where "public" static files are stored. Plasmic-managed image files will be stored as "plasmic/project-name/image-name" under this folder. Relative to srcDir; for example, "../public"
87
89
  */
@@ -81,7 +81,7 @@ function removeMissingFilesFromLock(context, config, lock) {
81
81
  image.id,
82
82
  image,
83
83
  ]));
84
- const knownIcons = Object.fromEntries(knownProjects[project.projectId].images.map((icons) => [
84
+ const knownIcons = Object.fromEntries(knownProjects[project.projectId].icons.map((icons) => [
85
85
  icons.id,
86
86
  icons,
87
87
  ]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.160",
3
+ "version": "0.1.164",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -556,8 +556,6 @@ async function syncProject(
556
556
  opts.baseDir
557
557
  );
558
558
 
559
- syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
560
-
561
559
  await syncProjectConfig(
562
560
  context,
563
561
  projectBundle.projectConfig,
@@ -572,6 +570,7 @@ async function syncProject(
572
570
  projectBundle.checksums,
573
571
  opts.baseDir
574
572
  );
573
+ syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
575
574
  await upsertStyleTokens(context, projectBundle.usedTokens);
576
575
  await syncProjectIconAssets(
577
576
  context,
@@ -629,8 +628,6 @@ async function syncProjectConfig(
629
628
  (p) => p.projectId === projectBundle.projectId
630
629
  );
631
630
 
632
- // If latest, use that as the range, otherwise set to latest published (>=0.0.0)
633
- const versionRange = semver.isLatest(version) ? version : ">=0.0.0";
634
631
  const projectConfig = getOrAddProjectConfig(
635
632
  context,
636
633
  projectBundle.projectId,
@@ -638,7 +635,7 @@ async function syncProjectConfig(
638
635
  projectId: projectBundle.projectId,
639
636
  projectApiToken,
640
637
  projectName: projectBundle.projectName,
641
- version: versionRange,
638
+ version,
642
639
  cssFilePath: defaultCssFilePath,
643
640
  })
644
641
  );
package/src/api.ts CHANGED
@@ -399,7 +399,7 @@ export class PlasmicApi {
399
399
 
400
400
  private get codegenHost() {
401
401
  if (!this.auth.host || this.auth.host === DEFAULT_HOST) {
402
- return this.auth.host;
402
+ return "https://codegen.plasmic.app";
403
403
  } else {
404
404
  return this.auth.host;
405
405
  }
@@ -367,7 +367,7 @@ function makeImportPath(
367
367
  fromPath: string,
368
368
  toPath: string,
369
369
  stripExt: boolean,
370
- forceRelative = false,
370
+ forceRelative = false
371
371
  ) {
372
372
  let result = toPath;
373
373
  if (forceRelative || isLocalModulePath(toPath)) {
@@ -448,7 +448,7 @@ export const mkFixImportContext = (config: PlasmicConfig) => {
448
448
  export async function fixAllImportStatements(
449
449
  context: PlasmicContext,
450
450
  baseDir: string,
451
- summary?: Map<string, ComponentUpdateSummary>,
451
+ summary?: Map<string, ComponentUpdateSummary>
452
452
  ) {
453
453
  logger.info("Fixing import statements...");
454
454
  const config = context.config;
@@ -468,7 +468,7 @@ export async function fixAllImportStatements(
468
468
  compConfig,
469
469
  fixImportContext,
470
470
  fixSkeletonModule,
471
- baseDir,
471
+ baseDir
472
472
  );
473
473
  }
474
474
  }
@@ -480,7 +480,7 @@ async function fixComponentImportStatements(
480
480
  compConfig: ComponentConfig,
481
481
  fixImportContext: FixImportContext,
482
482
  fixSkeletonModule: boolean,
483
- baseDir: string,
483
+ baseDir: string
484
484
  ) {
485
485
  // If ComponentConfig.importPath is still a local file, we best-effort also fix up the import statements there.
486
486
  if (
@@ -498,7 +498,7 @@ async function fixComponentImportStatements(
498
498
 
499
499
  let renderModuleChanged = false;
500
500
 
501
- if (context.config.images.scheme !== "inlined") {
501
+ if (["files", "public-files"].includes(context.config.images.scheme)) {
502
502
  await fixComponentCssReferences(
503
503
  context,
504
504
  fixImportContext,
@@ -520,7 +520,7 @@ async function fixComponentImportStatements(
520
520
  fixImportContext,
521
521
  false,
522
522
  baseDir,
523
- renderModuleChanged,
523
+ renderModuleChanged
524
524
  );
525
525
  }
526
526
 
@@ -608,7 +608,11 @@ export const tsxToJsx = (code: string) => {
608
608
  return fixPostTranspile(result.outputText);
609
609
  };
610
610
 
611
- export function maybeConvertTsxToJsx(fileName: string, content: string, baseDir: string) {
611
+ export function maybeConvertTsxToJsx(
612
+ fileName: string,
613
+ content: string,
614
+ baseDir: string
615
+ ) {
612
616
  if (fileName.endsWith("tsx")) {
613
617
  const jsFileName = stripExtension(fileName) + ".jsx";
614
618
  const jsContent = formatScript(tsxToJsx(content), baseDir);
@@ -116,8 +116,10 @@ export interface ImagesConfig {
116
116
  * * "files" - imported as relative files, like "import img from './image.png'". Not all bundlers support this.
117
117
  * * "public-files" - images are stored in a public folder, and referenced from some url prefix, like `<img src="/static/image.png"/>`.
118
118
  * * "inlined" - inlined directly into React files and css files as base64-encoded data-URIs.
119
+ * * "cdn" - images are served from Plasmic's CDN. Allows for dynamic resizing of images for
120
+ * serving the optimal file size given browser viewport.
119
121
  */
120
- scheme: "inlined" | "files" | "public-files";
122
+ scheme: "inlined" | "files" | "public-files" | "cdn";
121
123
 
122
124
  /**
123
125
  * The folder where "public" static files are stored. Plasmic-managed image files will be stored as "plasmic/project-name/image-name" under this folder. Relative to srcDir; for example, "../public"
@@ -79,7 +79,7 @@ function removeMissingFilesFromLock(
79
79
  ])
80
80
  );
81
81
  const knownIcons = Object.fromEntries(
82
- knownProjects[project.projectId].images.map((icons) => [
82
+ knownProjects[project.projectId].icons.map((icons) => [
83
83
  icons.id,
84
84
  icons,
85
85
  ])
package/tsconfig.json CHANGED
@@ -61,8 +61,7 @@
61
61
  // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
62
62
 
63
63
  /* Advanced Options */
64
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
65
- "skipLibCheck": true
64
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
66
65
  },
67
66
  "include": ["src"]
68
67
  }