@plasmicapp/cli 0.1.336 → 0.1.337

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/index.js CHANGED
@@ -499536,7 +499536,6 @@ async function fixRscModulesImports(context, baseDir, fixImportContext, compConf
499536
499536
  if (!modulePath) {
499537
499537
  continue;
499538
499538
  }
499539
- logger.info(`Fixing rsc import statements... ${modulePath}`);
499540
499539
  try {
499541
499540
  await fixFileImportStatements(
499542
499541
  context,
@@ -499861,11 +499860,15 @@ function readFileText(path15) {
499861
499860
  case "create":
499862
499861
  return ensureString(action.content);
499863
499862
  case "rename":
499864
- return readFileText(action.newPath);
499863
+ return import_fs.default.readFileSync(path15, "utf8");
499865
499864
  case "delete":
499866
499865
  throw new HandledError("File does not exists");
499867
499866
  }
499868
499867
  }
499868
+ const renamedFilePath = renamedFiles.get(path15);
499869
+ if (renamedFilePath) {
499870
+ return readFileText(renamedFilePath);
499871
+ }
499869
499872
  }
499870
499873
  return import_fs.default.readFileSync(path15, "utf8");
499871
499874
  }
@@ -502268,7 +502271,7 @@ var import_lodash15 = __toESM(require_lodash());
502268
502271
  var import_upath9 = __toESM(require_upath());
502269
502272
 
502270
502273
  // src/utils/rsc-config.ts
502271
- async function syncRscFiles(context, project, bundle, compConfig) {
502274
+ async function syncRscFiles(context, project, bundle, compConfig, opts) {
502272
502275
  const rscMetadata = bundle.rscMetadata;
502273
502276
  if (rscMetadata) {
502274
502277
  if (!compConfig.rsc) {
@@ -502296,19 +502299,22 @@ async function syncRscFiles(context, project, bundle, compConfig) {
502296
502299
  "-client.tsx"
502297
502300
  );
502298
502301
  compConfig.rsc.clientModulePath = clientModuleFilePath;
502299
- await writeFileContent(
502300
- context,
502301
- clientModuleFilePath,
502302
- rscMetadata.pageWrappers.client.module,
502303
- {
502304
- force: false
502305
- }
502306
- );
502302
+ if (opts.shouldRegenerate) {
502303
+ await writeFileContent(
502304
+ context,
502305
+ clientModuleFilePath,
502306
+ rscMetadata.pageWrappers.client.module,
502307
+ {
502308
+ force: false
502309
+ }
502310
+ );
502311
+ }
502307
502312
  }
502308
502313
  }
502309
502314
 
502310
502315
  // src/actions/sync-components.ts
502311
502316
  async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir) {
502317
+ var _a;
502312
502318
  const componentsFromChecksums = /* @__PURE__ */ new Set([
502313
502319
  ...checksums.cssRulesChecksums.map(([id, _]) => id),
502314
502320
  checksums.renderModuleChecksums.map(([id, _]) => id)
@@ -502467,6 +502473,23 @@ async function syncProjectComponents(context, project, version, componentBundles
502467
502473
  }
502468
502474
  renameFile(context, compConfig.importSpec.modulePath, skeletonPath);
502469
502475
  compConfig.importSpec.modulePath = skeletonPath;
502476
+ if (((_a = compConfig.rsc) == null ? void 0 : _a.clientModulePath) && fileExists(context, compConfig.rsc.clientModulePath)) {
502477
+ const clientModulePath = skeletonPath.replace(
502478
+ /\.tsx$/,
502479
+ "-client.tsx"
502480
+ );
502481
+ if (context.cliArgs.quiet !== true) {
502482
+ logger.info(
502483
+ `Renaming page file: ${compConfig.rsc.clientModulePath} -> ${clientModulePath} ['${project.projectName}' ${project.projectId}/${id} ${project.version}]`
502484
+ );
502485
+ }
502486
+ renameFile(
502487
+ context,
502488
+ compConfig.rsc.clientModulePath,
502489
+ clientModulePath
502490
+ );
502491
+ compConfig.rsc.clientModulePath = clientModulePath;
502492
+ }
502470
502493
  }
502471
502494
  compConfig.plumeType = plumeType;
502472
502495
  if (scheme === "direct") {
@@ -502534,7 +502557,9 @@ async function syncProjectComponents(context, project, version, componentBundles
502534
502557
  );
502535
502558
  }
502536
502559
  summary.set(id, { skeletonModuleModified });
502537
- await syncRscFiles(context, project, bundle, compConfig);
502560
+ await syncRscFiles(context, project, bundle, compConfig, {
502561
+ shouldRegenerate
502562
+ });
502538
502563
  }
502539
502564
  }
502540
502565
 
package/dist/lib.js CHANGED
@@ -494878,7 +494878,6 @@ async function fixRscModulesImports(context, baseDir, fixImportContext, compConf
494878
494878
  if (!modulePath) {
494879
494879
  continue;
494880
494880
  }
494881
- logger.info(`Fixing rsc import statements... ${modulePath}`);
494882
494881
  try {
494883
494882
  await fixFileImportStatements(
494884
494883
  context,
@@ -495203,11 +495202,15 @@ function readFileText(path15) {
495203
495202
  case "create":
495204
495203
  return ensureString(action.content);
495205
495204
  case "rename":
495206
- return readFileText(action.newPath);
495205
+ return import_fs.default.readFileSync(path15, "utf8");
495207
495206
  case "delete":
495208
495207
  throw new HandledError("File does not exists");
495209
495208
  }
495210
495209
  }
495210
+ const renamedFilePath = renamedFiles.get(path15);
495211
+ if (renamedFilePath) {
495212
+ return readFileText(renamedFilePath);
495213
+ }
495211
495214
  }
495212
495215
  return import_fs.default.readFileSync(path15, "utf8");
495213
495216
  }
@@ -497566,7 +497569,7 @@ var import_lodash15 = __toESM(require_lodash());
497566
497569
  var import_upath9 = __toESM(require_upath());
497567
497570
 
497568
497571
  // src/utils/rsc-config.ts
497569
- async function syncRscFiles(context, project, bundle, compConfig) {
497572
+ async function syncRscFiles(context, project, bundle, compConfig, opts) {
497570
497573
  const rscMetadata = bundle.rscMetadata;
497571
497574
  if (rscMetadata) {
497572
497575
  if (!compConfig.rsc) {
@@ -497594,19 +497597,22 @@ async function syncRscFiles(context, project, bundle, compConfig) {
497594
497597
  "-client.tsx"
497595
497598
  );
497596
497599
  compConfig.rsc.clientModulePath = clientModuleFilePath;
497597
- await writeFileContent(
497598
- context,
497599
- clientModuleFilePath,
497600
- rscMetadata.pageWrappers.client.module,
497601
- {
497602
- force: false
497603
- }
497604
- );
497600
+ if (opts.shouldRegenerate) {
497601
+ await writeFileContent(
497602
+ context,
497603
+ clientModuleFilePath,
497604
+ rscMetadata.pageWrappers.client.module,
497605
+ {
497606
+ force: false
497607
+ }
497608
+ );
497609
+ }
497605
497610
  }
497606
497611
  }
497607
497612
 
497608
497613
  // src/actions/sync-components.ts
497609
497614
  async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir) {
497615
+ var _a;
497610
497616
  const componentsFromChecksums = /* @__PURE__ */ new Set([
497611
497617
  ...checksums.cssRulesChecksums.map(([id, _]) => id),
497612
497618
  checksums.renderModuleChecksums.map(([id, _]) => id)
@@ -497765,6 +497771,23 @@ async function syncProjectComponents(context, project, version, componentBundles
497765
497771
  }
497766
497772
  renameFile(context, compConfig.importSpec.modulePath, skeletonPath);
497767
497773
  compConfig.importSpec.modulePath = skeletonPath;
497774
+ if (((_a = compConfig.rsc) == null ? void 0 : _a.clientModulePath) && fileExists(context, compConfig.rsc.clientModulePath)) {
497775
+ const clientModulePath = skeletonPath.replace(
497776
+ /\.tsx$/,
497777
+ "-client.tsx"
497778
+ );
497779
+ if (context.cliArgs.quiet !== true) {
497780
+ logger.info(
497781
+ `Renaming page file: ${compConfig.rsc.clientModulePath} -> ${clientModulePath} ['${project.projectName}' ${project.projectId}/${id} ${project.version}]`
497782
+ );
497783
+ }
497784
+ renameFile(
497785
+ context,
497786
+ compConfig.rsc.clientModulePath,
497787
+ clientModulePath
497788
+ );
497789
+ compConfig.rsc.clientModulePath = clientModulePath;
497790
+ }
497768
497791
  }
497769
497792
  compConfig.plumeType = plumeType;
497770
497793
  if (scheme === "direct") {
@@ -497832,7 +497855,9 @@ async function syncProjectComponents(context, project, version, componentBundles
497832
497855
  );
497833
497856
  }
497834
497857
  summary.set(id, { skeletonModuleModified });
497835
- await syncRscFiles(context, project, bundle, compConfig);
497858
+ await syncRscFiles(context, project, bundle, compConfig, {
497859
+ shouldRegenerate
497860
+ });
497836
497861
  }
497837
497862
  }
497838
497863
 
@@ -113,11 +113,14 @@
113
113
  "type": "string"
114
114
  },
115
115
  "rsc": {
116
+ "description": "RSC metadata for this component. The structure of the config changes when this is set:\nrenderModuleFilePath points to the client blackbox render module.\nimportSpec points to the server skeleton file.",
116
117
  "properties": {
117
118
  "clientModulePath": {
119
+ "description": "The client skeleton file",
118
120
  "type": "string"
119
121
  },
120
122
  "serverModulePath": {
123
+ "description": "The server blackbox render module",
121
124
  "type": "string"
122
125
  }
123
126
  },
@@ -206,8 +206,15 @@ export interface ComponentConfig {
206
206
  path?: string;
207
207
  /** Plume type if component is a Plume component */
208
208
  plumeType?: string;
209
+ /**
210
+ * RSC metadata for this component. The structure of the config changes when this is set:
211
+ * renderModuleFilePath points to the client blackbox render module.
212
+ * importSpec points to the server skeleton file.
213
+ */
209
214
  rsc?: {
215
+ /** The server blackbox render module */
210
216
  serverModulePath: string;
217
+ /** The client skeleton file */
211
218
  clientModulePath: string;
212
219
  };
213
220
  }
@@ -1,3 +1,5 @@
1
1
  import { ComponentBundle } from "../api";
2
2
  import { ComponentConfig, PlasmicContext, ProjectConfig } from "./config-utils";
3
- export declare function syncRscFiles(context: PlasmicContext, project: ProjectConfig, bundle: ComponentBundle, compConfig: ComponentConfig): Promise<void>;
3
+ export declare function syncRscFiles(context: PlasmicContext, project: ProjectConfig, bundle: ComponentBundle, compConfig: ComponentConfig, opts: {
4
+ shouldRegenerate: boolean;
5
+ }): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.336",
3
+ "version": "0.1.337",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -83,5 +83,5 @@
83
83
  "wrap-ansi": "^7.0.0",
84
84
  "yargs": "^15.4.1"
85
85
  },
86
- "gitHead": "e390ac2d296d887f8ed34f29fd85f21a315c35da"
86
+ "gitHead": "5dbcf9cb4a1be8f4060acbb9e3bdf698e99af7c6"
87
87
  }
@@ -232,6 +232,26 @@ export async function syncProjectComponents(
232
232
  }
233
233
  renameFile(context, compConfig.importSpec.modulePath, skeletonPath);
234
234
  compConfig.importSpec.modulePath = skeletonPath;
235
+ if (
236
+ compConfig.rsc?.clientModulePath &&
237
+ fileExists(context, compConfig.rsc.clientModulePath)
238
+ ) {
239
+ const clientModulePath = skeletonPath.replace(
240
+ /\.tsx$/,
241
+ "-client.tsx"
242
+ );
243
+ if (context.cliArgs.quiet !== true) {
244
+ logger.info(
245
+ `Renaming page file: ${compConfig.rsc.clientModulePath} -> ${clientModulePath}\t['${project.projectName}' ${project.projectId}/${id} ${project.version}]`
246
+ );
247
+ }
248
+ renameFile(
249
+ context,
250
+ compConfig.rsc.clientModulePath,
251
+ clientModulePath
252
+ );
253
+ compConfig.rsc.clientModulePath = clientModulePath;
254
+ }
235
255
  }
236
256
 
237
257
  compConfig.plumeType = plumeType;
@@ -306,6 +326,8 @@ export async function syncProjectComponents(
306
326
  }
307
327
  summary.set(id, { skeletonModuleModified });
308
328
 
309
- await syncRscFiles(context, project, bundle, compConfig);
329
+ await syncRscFiles(context, project, bundle, compConfig, {
330
+ shouldRegenerate,
331
+ });
310
332
  }
311
333
  }
@@ -946,8 +946,6 @@ export async function fixRscModulesImports(
946
946
  continue;
947
947
  }
948
948
 
949
- logger.info(`Fixing rsc import statements... ${modulePath}`);
950
-
951
949
  try {
952
950
  await fixFileImportStatements(
953
951
  context,
@@ -289,8 +289,15 @@ export interface ComponentConfig {
289
289
  /** Plume type if component is a Plume component */
290
290
  plumeType?: string;
291
291
 
292
+ /**
293
+ * RSC metadata for this component. The structure of the config changes when this is set:
294
+ * renderModuleFilePath points to the client blackbox render module.
295
+ * importSpec points to the server skeleton file.
296
+ */
292
297
  rsc?: {
298
+ /** The server blackbox render module */
293
299
  serverModulePath: string;
300
+ /** The client skeleton file */
294
301
  clientModulePath: string;
295
302
  };
296
303
  }
@@ -463,11 +463,18 @@ export function readFileText(path: string): string {
463
463
  case "create":
464
464
  return ensureString(action.content);
465
465
  case "rename":
466
- return readFileText(action.newPath);
466
+ // eslint-disable-next-line no-restricted-properties
467
+ return fs.readFileSync(path, "utf8");
467
468
  case "delete":
468
469
  throw new HandledError("File does not exists");
469
470
  }
470
471
  }
472
+ // If we are buffering files and the file has been renamed, only the old file path
473
+ // exists in disk, so we need to read the content from the old file path.
474
+ const renamedFilePath = renamedFiles.get(path);
475
+ if (renamedFilePath) {
476
+ return readFileText(renamedFilePath);
477
+ }
471
478
  }
472
479
 
473
480
  // eslint-disable-next-line no-restricted-properties
@@ -503,7 +510,6 @@ export function renameFileBuffered(oldPath: string, newPath: string) {
503
510
  if (renamedFile !== undefined) {
504
511
  oldPath = renamedFile;
505
512
  }
506
-
507
513
  buffer.set(oldPath, { type: "rename", newPath });
508
514
  renamedFiles.set(newPath, oldPath);
509
515
  } else {
@@ -6,7 +6,10 @@ export async function syncRscFiles(
6
6
  context: PlasmicContext,
7
7
  project: ProjectConfig,
8
8
  bundle: ComponentBundle,
9
- compConfig: ComponentConfig
9
+ compConfig: ComponentConfig,
10
+ opts: {
11
+ shouldRegenerate: boolean;
12
+ }
10
13
  ) {
11
14
  const rscMetadata = bundle.rscMetadata;
12
15
  if (rscMetadata) {
@@ -39,13 +42,15 @@ export async function syncRscFiles(
39
42
  );
40
43
  compConfig.rsc.clientModulePath = clientModuleFilePath;
41
44
 
42
- await writeFileContent(
43
- context,
44
- clientModuleFilePath,
45
- rscMetadata.pageWrappers.client.module,
46
- {
47
- force: false,
48
- }
49
- );
45
+ if (opts.shouldRegenerate) {
46
+ await writeFileContent(
47
+ context,
48
+ clientModuleFilePath,
49
+ rscMetadata.pageWrappers.client.module,
50
+ {
51
+ force: false,
52
+ }
53
+ );
54
+ }
50
55
  }
51
56
  }