@plasmicapp/cli 0.1.353 → 0.1.354

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.
Files changed (34) hide show
  1. package/dist/__tests__/envdetect.spec.d.ts +1 -0
  2. package/dist/actions/sync-components.d.ts +1 -1
  3. package/dist/actions/sync-data-tokens.d.ts +1 -1
  4. package/dist/actions/sync-global-contexts.d.ts +1 -1
  5. package/dist/actions/sync-global-variants.d.ts +1 -1
  6. package/dist/actions/sync-icons.d.ts +1 -1
  7. package/dist/actions/sync-project-module.d.ts +1 -1
  8. package/dist/actions/sync-splits-provider.d.ts +1 -1
  9. package/dist/actions/sync-style-tokens-provider.d.ts +1 -1
  10. package/dist/index.js +245 -257
  11. package/dist/lib.js +245 -257
  12. package/dist/utils/code-utils.d.ts +6 -6
  13. package/dist/utils/config-utils.d.ts +3 -3
  14. package/dist/utils/envdetect.d.ts +1 -1
  15. package/package.json +2 -2
  16. package/src/__tests__/code-utils-spec.ts +6 -9
  17. package/src/__tests__/envdetect.spec.ts +115 -0
  18. package/src/actions/export.ts +110 -120
  19. package/src/actions/fix-imports.ts +5 -3
  20. package/src/actions/init.ts +5 -4
  21. package/src/actions/sync-components.ts +2 -6
  22. package/src/actions/sync-data-tokens.ts +2 -4
  23. package/src/actions/sync-global-contexts.ts +5 -6
  24. package/src/actions/sync-global-variants.ts +3 -8
  25. package/src/actions/sync-icons.ts +3 -4
  26. package/src/actions/sync-project-module.ts +5 -6
  27. package/src/actions/sync-splits-provider.ts +5 -6
  28. package/src/actions/sync-style-tokens-provider.ts +5 -7
  29. package/src/actions/sync.ts +15 -30
  30. package/src/migrations/migrations.ts +3 -3
  31. package/src/utils/code-utils.ts +15 -44
  32. package/src/utils/config-utils.ts +7 -21
  33. package/src/utils/envdetect.ts +42 -5
  34. package/src/utils/rsc-config.ts +29 -12
package/dist/index.js CHANGED
@@ -474480,7 +474480,7 @@ var require_src5 = __commonJS2({
474480
474480
  Object.defineProperty(exports, "__esModule", { value: true });
474481
474481
  var fs42 = __importStar7(__require("fs"));
474482
474482
  var path142 = __importStar7(__require("path"));
474483
- var semver3 = {
474483
+ var semver4 = {
474484
474484
  gte: require_gte2()
474485
474485
  };
474486
474486
  var fnmatch_1 = __importDefault7(require_fnmatch());
@@ -474509,7 +474509,7 @@ var require_src5 = __commonJS2({
474509
474509
  return paths;
474510
474510
  }
474511
474511
  function processMatches(matches, version) {
474512
- if ("indent_style" in matches && matches.indent_style === "tab" && !("indent_size" in matches) && semver3.gte(version, "0.10.0")) {
474512
+ if ("indent_style" in matches && matches.indent_style === "tab" && !("indent_size" in matches) && semver4.gte(version, "0.10.0")) {
474513
474513
  matches.indent_size = "tab";
474514
474514
  }
474515
474515
  if ("indent_size" in matches && !("tab_width" in matches) && matches.indent_size !== "tab") {
@@ -485387,7 +485387,7 @@ init_import_meta_url();
485387
485387
  var import_lodash = __toESM(require_lodash());
485388
485388
  var MODULE_NAME = "plasmic-data-tokens";
485389
485389
  var DEFAULT_DATA_TOKENS_NAME = MODULE_NAME;
485390
- async function syncDataTokens(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
485390
+ async function syncDataTokens(context, projectMeta, projectConfig, projectLock, checksums) {
485391
485391
  const resourcePath = getDataTokensResourcePath(context, projectConfig);
485392
485392
  if (checksums.dataTokensChecksum && projectMeta.dataTokensBundle) {
485393
485393
  if (context.cliArgs.quiet !== true) {
@@ -485397,8 +485397,7 @@ async function syncDataTokens(context, projectMeta, projectConfig, projectLock,
485397
485397
  }
485398
485398
  if (context.config.code.lang === "js") {
485399
485399
  projectMeta.dataTokensBundle.module = await formatScript(
485400
- tsxToJsx(projectMeta.dataTokensBundle.module),
485401
- baseDir
485400
+ tsxToJsx(projectMeta.dataTokensBundle.module)
485402
485401
  );
485403
485402
  }
485404
485403
  writeFileContent(
@@ -485449,7 +485448,7 @@ init_import_meta_url();
485449
485448
  var import_lodash2 = __toESM(require_lodash());
485450
485449
  var COMPONENT_NAME = "PlasmicGlobalContextsProvider";
485451
485450
  var DEFAULT_GLOBAL_CONTEXTS_NAME = COMPONENT_NAME;
485452
- async function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
485451
+ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, checksums) {
485453
485452
  const resourcePath = getGlobalContextsResourcePath(context, projectConfig);
485454
485453
  if (checksums.globalContextsChecksum && projectMeta.globalContextBundle) {
485455
485454
  if (context.cliArgs.quiet !== true) {
@@ -485459,8 +485458,7 @@ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLo
485459
485458
  }
485460
485459
  if (context.config.code.lang === "js") {
485461
485460
  projectMeta.globalContextBundle.contextModule = await formatScript(
485462
- tsxToJsx(projectMeta.globalContextBundle.contextModule),
485463
- baseDir
485461
+ tsxToJsx(projectMeta.globalContextBundle.contextModule)
485464
485462
  );
485465
485463
  }
485466
485464
  await writeFileContent(
@@ -485471,7 +485469,7 @@ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLo
485471
485469
  );
485472
485470
  projectConfig.globalContextsFilePath = resourcePath;
485473
485471
  const fl5 = projectLock.fileLocks.find(
485474
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "globalContexts"
485472
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "globalContexts"
485475
485473
  );
485476
485474
  if (fl5) {
485477
485475
  fl5.checksum = checksums.globalContextsChecksum;
@@ -485714,7 +485712,7 @@ init_import_meta_url();
485714
485712
  var import_lodash5 = __toESM(require_lodash());
485715
485713
  var MODULE_NAME2 = "plasmic";
485716
485714
  var DEFAULT_PROJECT_MODULE_NAME = MODULE_NAME2;
485717
- async function syncProjectModule(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
485715
+ async function syncProjectModule(context, projectMeta, projectConfig, projectLock, checksums) {
485718
485716
  const resourcePath = getProjectModuleResourcePath(context, projectConfig);
485719
485717
  if (checksums.projectModuleChecksum && projectMeta.projectModuleBundle) {
485720
485718
  if (context.cliArgs.quiet !== true) {
@@ -485724,8 +485722,7 @@ async function syncProjectModule(context, projectMeta, projectConfig, projectLoc
485724
485722
  }
485725
485723
  if (context.config.code.lang === "js") {
485726
485724
  projectMeta.projectModuleBundle.module = await formatScript(
485727
- tsxToJsx(projectMeta.projectModuleBundle.module),
485728
- baseDir
485725
+ tsxToJsx(projectMeta.projectModuleBundle.module)
485729
485726
  );
485730
485727
  }
485731
485728
  await writeFileContent(
@@ -485736,7 +485733,7 @@ async function syncProjectModule(context, projectMeta, projectConfig, projectLoc
485736
485733
  );
485737
485734
  projectConfig.projectModuleFilePath = resourcePath;
485738
485735
  const fl5 = projectLock.fileLocks.find(
485739
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "projectModule"
485736
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "projectModule"
485740
485737
  );
485741
485738
  if (fl5) {
485742
485739
  fl5.checksum = checksums.projectModuleChecksum || "";
@@ -485771,7 +485768,7 @@ init_import_meta_url();
485771
485768
  var import_lodash6 = __toESM(require_lodash());
485772
485769
  var COMPONENT_NAME2 = "PlasmicSplitsProvider";
485773
485770
  var DEFAULT_SPLITS_PROVIDER_NAME = COMPONENT_NAME2;
485774
- async function syncSplitsProvider(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
485771
+ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLock, checksums) {
485775
485772
  const resourcePath = getSplitsProviderResourcePath(context, projectConfig);
485776
485773
  if (checksums.splitsProviderChecksum && projectMeta.splitsProviderBundle) {
485777
485774
  if (context.cliArgs.quiet !== true) {
@@ -485781,8 +485778,7 @@ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLo
485781
485778
  }
485782
485779
  if (context.config.code.lang === "js") {
485783
485780
  projectMeta.splitsProviderBundle.module = await formatScript(
485784
- tsxToJsx(projectMeta.splitsProviderBundle.module),
485785
- baseDir
485781
+ tsxToJsx(projectMeta.splitsProviderBundle.module)
485786
485782
  );
485787
485783
  }
485788
485784
  await writeFileContent(
@@ -485793,7 +485789,7 @@ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLo
485793
485789
  );
485794
485790
  projectConfig.splitsProviderFilePath = resourcePath;
485795
485791
  const fl5 = projectLock.fileLocks.find(
485796
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "splitsProvider"
485792
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "splitsProvider"
485797
485793
  );
485798
485794
  if (fl5) {
485799
485795
  fl5.checksum = checksums.splitsProviderChecksum;
@@ -485828,7 +485824,7 @@ init_import_meta_url();
485828
485824
  var import_lodash7 = __toESM(require_lodash());
485829
485825
  var MODULE_NAME3 = "PlasmicStyleTokensProvider";
485830
485826
  var DEFAULT_STYLE_TOKENS_PROVIDER_NAME = MODULE_NAME3;
485831
- async function syncStyleTokensProvider(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
485827
+ async function syncStyleTokensProvider(context, projectMeta, projectConfig, projectLock, checksums) {
485832
485828
  const resourcePath = getStyleTokensProviderResourcePath(
485833
485829
  context,
485834
485830
  projectConfig
@@ -485841,8 +485837,7 @@ async function syncStyleTokensProvider(context, projectMeta, projectConfig, proj
485841
485837
  }
485842
485838
  if (context.config.code.lang === "js") {
485843
485839
  projectMeta.styleTokensProviderBundle.module = await formatScript(
485844
- tsxToJsx(projectMeta.styleTokensProviderBundle.module),
485845
- baseDir
485840
+ tsxToJsx(projectMeta.styleTokensProviderBundle.module)
485846
485841
  );
485847
485842
  }
485848
485843
  writeFileContent(
@@ -485853,7 +485848,7 @@ async function syncStyleTokensProvider(context, projectMeta, projectConfig, proj
485853
485848
  );
485854
485849
  projectConfig.styleTokensProviderFilePath = resourcePath;
485855
485850
  const fl5 = projectLock.fileLocks.find(
485856
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "styleTokensProvider"
485851
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "styleTokensProvider"
485857
485852
  );
485858
485853
  if (fl5) {
485859
485854
  fl5.checksum = checksums.styleTokensProviderChecksum || "";
@@ -485890,7 +485885,7 @@ var GLOBAL_SETTINGS = {
485890
485885
  };
485891
485886
 
485892
485887
  // src/utils/code-utils.ts
485893
- async function formatAsLocal(content, filePath, baseDir, defaultOpts) {
485888
+ async function formatAsLocal(content, filePath, defaultOpts) {
485894
485889
  if (GLOBAL_SETTINGS.skipFormatting) {
485895
485890
  return content;
485896
485891
  }
@@ -485904,12 +485899,12 @@ async function formatAsLocal(content, filePath, baseDir, defaultOpts) {
485904
485899
  const res2 = await format2(res, opts);
485905
485900
  return res2;
485906
485901
  }
485907
- async function nodeToFormattedCode(n26, baseDir, unformatted, commentsToRemove) {
485902
+ async function nodeToFormattedCode(n26, unformatted, commentsToRemove) {
485908
485903
  const c5 = (0, import_generator.default)(n26, {
485909
485904
  retainLines: true,
485910
485905
  shouldPrintComment: (comment) => !commentsToRemove || !commentsToRemove.has(comment)
485911
485906
  }).code;
485912
- return unformatted ? c5 : await formatAsLocal(c5, "/tmp/x.tsx", baseDir, {
485907
+ return unformatted ? c5 : await formatAsLocal(c5, "/tmp/x.tsx", {
485913
485908
  arrowParens: "avoid"
485914
485909
  });
485915
485910
  }
@@ -485997,7 +485992,7 @@ function filterUnformattedMarker(code, changed) {
485997
485992
  code = lines.filter((line3) => !isUnformattedMarker(line3)).join("\n");
485998
485993
  return [code, changed];
485999
485994
  }
486000
- async function replaceImports(context, code, fromPath, fixImportContext, removeImportDirective, baseDir, changed = false) {
485995
+ async function replaceImports(context, code, fromPath, fixImportContext, removeImportDirective, changed = false) {
486001
485996
  [code, changed] = filterUnformattedMarker(code, changed);
486002
485997
  const file = parser.parse(code, {
486003
485998
  strictMode: true,
@@ -486241,7 +486236,7 @@ async function replaceImports(context, code, fromPath, fixImportContext, removeI
486241
486236
  if (!changed) {
486242
486237
  return code;
486243
486238
  }
486244
- return nodeToFormattedCode(file, baseDir, !changed, commentsToRemove);
486239
+ return nodeToFormattedCode(file, !changed, commentsToRemove);
486245
486240
  }
486246
486241
  function throwMissingReference(context, itemType, uuid, fromPath) {
486247
486242
  let recFix = `Please make sure projects that "${uuid}" depends on have already been synced.`;
@@ -486322,7 +486317,7 @@ var mkFixImportContext = (config) => {
486322
486317
  projects
486323
486318
  };
486324
486319
  };
486325
- async function fixAllImportStatements(context, baseDir, summary) {
486320
+ async function fixAllImportStatements(context, summary) {
486326
486321
  logger.info("Fixing import statements...");
486327
486322
  const config = context.config;
486328
486323
  const fixImportContext = mkFixImportContext(config);
@@ -486330,12 +486325,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
486330
486325
  for (const project of config.projects) {
486331
486326
  for (const compConfig of project.components) {
486332
486327
  try {
486333
- await fixRscModulesImports(
486334
- context,
486335
- baseDir,
486336
- fixImportContext,
486337
- compConfig
486338
- );
486328
+ await fixRscModulesImports(context, fixImportContext, compConfig);
486339
486329
  } catch (err) {
486340
486330
  lastError = err;
486341
486331
  }
@@ -486350,8 +486340,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
486350
486340
  context,
486351
486341
  compConfig,
486352
486342
  fixImportContext,
486353
- fixSkeletonModule,
486354
- baseDir
486343
+ fixSkeletonModule
486355
486344
  );
486356
486345
  } catch (err) {
486357
486346
  logger.error(
@@ -486363,7 +486352,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
486363
486352
  }
486364
486353
  }
486365
486354
  try {
486366
- await fixGlobalContextImportStatements(context, fixImportContext, baseDir);
486355
+ await fixGlobalContextImportStatements(context, fixImportContext);
486367
486356
  } catch (err) {
486368
486357
  logger.error(
486369
486358
  `Error encountered while fixing imports for global contexts: ${err}`
@@ -486374,7 +486363,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
486374
486363
  await fixImportStatements(
486375
486364
  context,
486376
486365
  fixImportContext,
486377
- baseDir,
486378
486366
  "splitsProviderFilePath",
486379
486367
  getSplitsProviderResourcePath
486380
486368
  );
@@ -486388,7 +486376,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
486388
486376
  await fixImportStatements(
486389
486377
  context,
486390
486378
  fixImportContext,
486391
- baseDir,
486392
486379
  "projectModuleFilePath",
486393
486380
  getProjectModuleResourcePath
486394
486381
  );
@@ -486402,7 +486389,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
486402
486389
  await fixImportStatements(
486403
486390
  context,
486404
486391
  fixImportContext,
486405
- baseDir,
486406
486392
  "styleTokensProviderFilePath",
486407
486393
  getStyleTokensProviderResourcePath
486408
486394
  );
@@ -486416,7 +486402,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
486416
486402
  await fixImportStatements(
486417
486403
  context,
486418
486404
  fixImportContext,
486419
- baseDir,
486420
486405
  "dataTokensFilePath",
486421
486406
  getDataTokensResourcePath
486422
486407
  );
@@ -486430,14 +486415,13 @@ async function fixAllImportStatements(context, baseDir, summary) {
486430
486415
  throw lastError;
486431
486416
  }
486432
486417
  }
486433
- async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule, baseDir) {
486418
+ async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule) {
486434
486419
  if (compConfig.type !== "mapped" && isLocalModulePath(compConfig.importSpec.modulePath) && fixSkeletonModule) {
486435
486420
  await fixFileImportStatements(
486436
486421
  context,
486437
486422
  compConfig.importSpec.modulePath,
486438
486423
  fixImportContext,
486439
- true,
486440
- baseDir
486424
+ true
486441
486425
  );
486442
486426
  }
486443
486427
  let renderModuleChanged = false;
@@ -486460,11 +486444,10 @@ async function fixComponentImportStatements(context, compConfig, fixImportContex
486460
486444
  compConfig.renderModuleFilePath,
486461
486445
  fixImportContext,
486462
486446
  false,
486463
- baseDir,
486464
486447
  renderModuleChanged
486465
486448
  );
486466
486449
  }
486467
- async function fixFileImportStatements(context, srcDirFilePath, fixImportContext, removeImportDirective, baseDir, fileHasChanged = false) {
486450
+ async function fixFileImportStatements(context, srcDirFilePath, fixImportContext, removeImportDirective, fileHasChanged = false) {
486468
486451
  const filePath = makeFilePath(context, srcDirFilePath);
486469
486452
  if (!existsBuffered(filePath)) {
486470
486453
  logger.warn(
@@ -486479,7 +486462,6 @@ async function fixFileImportStatements(context, srcDirFilePath, fixImportContext
486479
486462
  srcDirFilePath,
486480
486463
  fixImportContext,
486481
486464
  removeImportDirective,
486482
- baseDir,
486483
486465
  fileHasChanged
486484
486466
  );
486485
486467
  if (prevContent !== newContent) {
@@ -486528,15 +486510,15 @@ var tsxToJsx = (code) => {
486528
486510
  });
486529
486511
  return fixPostTranspile(result.outputText);
486530
486512
  };
486531
- async function maybeConvertTsxToJsx(fileName, content, baseDir) {
486513
+ async function maybeConvertTsxToJsx(fileName, content) {
486532
486514
  if (fileName.endsWith("tsx")) {
486533
486515
  const jsFileName = stripExtension(fileName) + ".jsx";
486534
- const jsContent = await formatScript(tsxToJsx(content), baseDir);
486516
+ const jsContent = await formatScript(tsxToJsx(content));
486535
486517
  return [jsFileName, jsContent];
486536
486518
  }
486537
486519
  return [fileName, content];
486538
486520
  }
486539
- async function formatScript(code, baseDir) {
486521
+ async function formatScript(code) {
486540
486522
  const file = parser.parse(code, {
486541
486523
  strictMode: true,
486542
486524
  sourceType: "module",
@@ -486554,18 +486536,18 @@ async function formatScript(code, baseDir) {
486554
486536
  }
486555
486537
  }
486556
486538
  });
486557
- const withmarkers = await nodeToFormattedCode(file, baseDir, true);
486539
+ const withmarkers = await nodeToFormattedCode(file, true);
486558
486540
  const withNewLines = withmarkers.replace(
486559
486541
  new RegExp(`"${newLineMarker}"`, "g"),
486560
486542
  "\n"
486561
486543
  );
486562
- return await formatAsLocal(withNewLines, "/tmp/x.tsx", baseDir, {
486544
+ return await formatAsLocal(withNewLines, "/tmp/x.tsx", {
486563
486545
  printWidth: 80,
486564
486546
  tabWidth: 2,
486565
486547
  useTabs: false
486566
486548
  });
486567
486549
  }
486568
- async function fixGlobalContextImportStatements(context, fixImportContext, baseDir) {
486550
+ async function fixGlobalContextImportStatements(context, fixImportContext) {
486569
486551
  for (const project of context.config.projects) {
486570
486552
  if (!project.globalContextsFilePath) {
486571
486553
  continue;
@@ -486588,7 +486570,6 @@ async function fixGlobalContextImportStatements(context, fixImportContext, baseD
486588
486570
  resourcePath,
486589
486571
  fixImportContext,
486590
486572
  false,
486591
- baseDir,
486592
486573
  true
486593
486574
  );
486594
486575
  if (prevContent !== newContent) {
@@ -486598,7 +486579,7 @@ async function fixGlobalContextImportStatements(context, fixImportContext, baseD
486598
486579
  }
486599
486580
  }
486600
486581
  }
486601
- async function fixImportStatements(context, fixImportContext, baseDir, configKey, getResourcePath) {
486582
+ async function fixImportStatements(context, fixImportContext, configKey, getResourcePath) {
486602
486583
  for (const project of context.config.projects) {
486603
486584
  if (!project[configKey]) {
486604
486585
  continue;
@@ -486621,7 +486602,6 @@ async function fixImportStatements(context, fixImportContext, baseDir, configKey
486621
486602
  resourcePath,
486622
486603
  fixImportContext,
486623
486604
  false,
486624
- baseDir,
486625
486605
  true
486626
486606
  );
486627
486607
  if (prevContent !== newContent) {
@@ -486631,7 +486611,7 @@ async function fixImportStatements(context, fixImportContext, baseDir, configKey
486631
486611
  }
486632
486612
  }
486633
486613
  }
486634
- async function fixRscModulesImports(context, baseDir, fixImportContext, compConfig) {
486614
+ async function fixRscModulesImports(context, fixImportContext, compConfig) {
486635
486615
  var _a8, _b2;
486636
486616
  const errors = [];
486637
486617
  for (const modulePath of [
@@ -486646,8 +486626,7 @@ async function fixRscModulesImports(context, baseDir, fixImportContext, compConf
486646
486626
  context,
486647
486627
  modulePath,
486648
486628
  fixImportContext,
486649
- false,
486650
- baseDir
486629
+ false
486651
486630
  );
486652
486631
  } catch (err) {
486653
486632
  logger.error(
@@ -487343,7 +487322,7 @@ function readConfig(configFile, autoFillDefaults) {
487343
487322
  throw e7;
487344
487323
  }
487345
487324
  }
487346
- async function writeConfig(configFile, config, baseDir) {
487325
+ async function writeConfig(configFile, config) {
487347
487326
  await writeFileContentRaw(
487348
487327
  configFile,
487349
487328
  await formatAsLocal(
@@ -487355,31 +487334,26 @@ async function writeConfig(configFile, config, baseDir) {
487355
487334
  void 0,
487356
487335
  2
487357
487336
  ),
487358
- configFile,
487359
- baseDir
487337
+ configFile
487360
487338
  ),
487361
487339
  {
487362
487340
  force: true
487363
487341
  }
487364
487342
  );
487365
487343
  }
487366
- async function writeLock(lockFile, lock, baseDir) {
487344
+ async function writeLock(lockFile, lock) {
487367
487345
  await writeFileContentRaw(
487368
487346
  lockFile,
487369
- await formatAsLocal(
487370
- JSON.stringify(lock, void 0, 2),
487371
- "/tmp/x.json",
487372
- baseDir
487373
- ),
487347
+ await formatAsLocal(JSON.stringify(lock, void 0, 2), "/tmp/x.json"),
487374
487348
  {
487375
487349
  force: true
487376
487350
  }
487377
487351
  );
487378
487352
  }
487379
- async function updateConfig(context, newConfig, baseDir) {
487380
- await writeConfig(context.configFile, newConfig, baseDir);
487353
+ async function updateConfig(context, newConfig) {
487354
+ await writeConfig(context.configFile, newConfig);
487381
487355
  context.config = newConfig;
487382
- await writeLock(context.lockFile, context.lock, baseDir);
487356
+ await writeLock(context.lockFile, context.lock);
487383
487357
  }
487384
487358
  function getOrAddProjectConfig(context, projectId, base) {
487385
487359
  let project = context.config.projects.find((p5) => p5.projectId === projectId);
@@ -487902,11 +487876,18 @@ var import_upath5 = __toESM(require_upath());
487902
487876
  // src/utils/envdetect.ts
487903
487877
  init_import_meta_url();
487904
487878
  var import_findup_sync2 = __toESM(require_findup_sync());
487879
+ var import_semver2 = __toESM(require_semver2());
487905
487880
  function detectTypescript() {
487906
487881
  return (0, import_findup_sync2.default)("tsconfig.json");
487907
487882
  }
487908
487883
  function detectNextJs() {
487909
- if ((0, import_findup_sync2.default)("next.config.js") || (0, import_findup_sync2.default)(".next") || (0, import_findup_sync2.default)("next-env.d.ts")) {
487884
+ if ((0, import_findup_sync2.default)([
487885
+ "next.config.js",
487886
+ "next.config.ts",
487887
+ "next.config.mjs",
487888
+ ".next/",
487889
+ "next-env.d.ts"
487890
+ ])) {
487910
487891
  return true;
487911
487892
  }
487912
487893
  try {
@@ -487917,12 +487898,36 @@ function detectNextJs() {
487917
487898
  }
487918
487899
  }
487919
487900
  function detectNextJsAppDir() {
487920
- var _a8, _b2;
487901
+ var _a8, _b2, _c3;
487902
+ if (!detectNextJs()) {
487903
+ return false;
487904
+ }
487921
487905
  const nextConfigPath = (0, import_findup_sync2.default)("next.config.js");
487922
- if (!nextConfigPath) {
487906
+ if (nextConfigPath && ((_b2 = (_a8 = require(nextConfigPath)) == null ? void 0 : _a8.experimental) == null ? void 0 : _b2.appDir)) {
487907
+ return true;
487908
+ }
487909
+ if (!(0, import_findup_sync2.default)("app")) {
487923
487910
  return false;
487924
487911
  }
487925
- return ((_b2 = (_a8 = require(nextConfigPath)) == null ? void 0 : _a8.experimental) == null ? void 0 : _b2.appDir) || false;
487912
+ if (!(0, import_findup_sync2.default)("pages")) {
487913
+ return true;
487914
+ }
487915
+ try {
487916
+ const packageJson = getParsedPackageJson();
487917
+ const nextVersion = (_c3 = packageJson.dependencies) == null ? void 0 : _c3.next;
487918
+ if (nextVersion) {
487919
+ if (nextVersion === "latest") {
487920
+ return true;
487921
+ }
487922
+ const coercedVersion = import_semver2.default.coerce(nextVersion);
487923
+ if (coercedVersion && import_semver2.default.gte(coercedVersion, "13.4.0")) {
487924
+ return true;
487925
+ }
487926
+ }
487927
+ } catch {
487928
+ return false;
487929
+ }
487930
+ return false;
487926
487931
  }
487927
487932
  function detectGatsby() {
487928
487933
  return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
@@ -487946,8 +487951,9 @@ function detectTanStackApp() {
487946
487951
 
487947
487952
  // src/actions/init.ts
487948
487953
  async function initPlasmic(opts) {
487949
- if (!opts.baseDir)
487954
+ if (!opts.baseDir) {
487950
487955
  opts.baseDir = process.cwd();
487956
+ }
487951
487957
  await getOrStartAuth(opts);
487952
487958
  const configFile = opts.config || findConfigFile(opts.baseDir, { traverseParents: false });
487953
487959
  if (configFile && existsBuffered(configFile)) {
@@ -487959,7 +487965,7 @@ async function initPlasmic(opts) {
487959
487965
  const newConfigFile = opts.config || import_upath5.default.join(opts.baseDir, CONFIG_FILE_NAME);
487960
487966
  const answers = await deriveInitAnswers(opts);
487961
487967
  const initConfig = createInitConfig(answers);
487962
- await writeConfig(newConfigFile, initConfig, opts.baseDir);
487968
+ await writeConfig(newConfigFile, initConfig);
487963
487969
  if (!process.env.QUIET) {
487964
487970
  logger.info("Successfully created plasmic.json.\n");
487965
487971
  }
@@ -488023,7 +488029,7 @@ function simulatePrompt(question, defaultAnswer, bold = false) {
488023
488029
  }
488024
488030
  async function deriveInitAnswers(opts) {
488025
488031
  const plasmicRootDir = opts.config ? import_upath5.default.dirname(opts.config) : opts.baseDir;
488026
- const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
488032
+ const platform = opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
488027
488033
  const isCra = platform === "react";
488028
488034
  const isNext = platform === "nextjs";
488029
488035
  const isNextAppDir = isNext && detectNextJsAppDir();
@@ -488091,7 +488097,6 @@ async function deriveInitAnswers(opts) {
488091
488097
  pagesDir: getDefaultAnswer("pagesDir", void 0),
488092
488098
  reactRuntime: getDefaultAnswer("reactRuntime", "classic")
488093
488099
  };
488094
- const prominentAnswers = import_lodash11.default.omit(answers, "codeScheme");
488095
488100
  if (process.env.QUIET) {
488096
488101
  return answers;
488097
488102
  }
@@ -488423,7 +488428,7 @@ function getYargsOption(key2, defaultOverride) {
488423
488428
  init_import_meta_url();
488424
488429
  var import_chalk3 = __toESM(require_source());
488425
488430
  var import_lodash13 = __toESM(require_lodash());
488426
- var import_semver2 = __toESM(require_semver2());
488431
+ var import_semver3 = __toESM(require_semver2());
488427
488432
  var import_upath7 = __toESM(require_upath());
488428
488433
 
488429
488434
  // src/migrations/0.1.110-fileLocks.ts
@@ -488574,7 +488579,7 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
488574
488579
  };
488575
488580
  const cur = readConfig(configFile, false);
488576
488581
  const curVersion = cur.cliVersion;
488577
- if (!!curVersion && import_semver2.default.lt(cliVersion, curVersion)) {
488582
+ if (!!curVersion && import_semver3.default.lt(cliVersion, curVersion)) {
488578
488583
  const confirm = await confirmWithUser(
488579
488584
  `Project requires @plasmicapp/cli>=${curVersion} (You currently have ${cliVersion}). Would you like to upgrade it?`,
488580
488585
  yes
@@ -488594,9 +488599,9 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
488594
488599
  const context = {
488595
488600
  absoluteSrcDir: import_upath7.default.isAbsolute(cur.srcDir) ? cur.srcDir : import_upath7.default.resolve(import_upath7.default.dirname(configFile), cur.srcDir)
488596
488601
  };
488597
- const greaterVersions = import_semver2.default.sort(
488602
+ const greaterVersions = import_semver3.default.sort(
488598
488603
  [...import_lodash13.default.keys(MIGRATIONS), ...import_lodash13.default.keys(LOCK_MIGRATIONS)].filter(
488599
- (v7) => !curVersion || import_semver2.default.gt(v7, curVersion)
488604
+ (v7) => !curVersion || import_semver3.default.gt(v7, curVersion)
488600
488605
  )
488601
488606
  );
488602
488607
  for (const version of greaterVersions) {
@@ -488606,21 +488611,21 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
488606
488611
  const prev2 = readConfig(configFile, false);
488607
488612
  const next = migrationFunc(prev2, context);
488608
488613
  next.cliVersion = version;
488609
- await writeConfig(configFile, next, baseDir);
488614
+ await writeConfig(configFile, next);
488610
488615
  }
488611
488616
  const lockMigrationFunc = LOCK_MIGRATIONS[version];
488612
488617
  if (lockMigrationFunc !== void 0) {
488613
488618
  const prev2 = maybeReadLock();
488614
488619
  if (prev2) {
488615
488620
  const next = lockMigrationFunc(prev2, context);
488616
- await writeLock(lockFile, next, baseDir);
488621
+ await writeLock(lockFile, next);
488617
488622
  }
488618
488623
  }
488619
488624
  }
488620
488625
  const latestConfig = readConfig(configFile, false);
488621
488626
  if (latestConfig.cliVersion !== cliVersion) {
488622
488627
  latestConfig.cliVersion = cliVersion;
488623
- await writeConfig(configFile, latestConfig, baseDir);
488628
+ await writeConfig(configFile, latestConfig);
488624
488629
  }
488625
488630
  }
488626
488631
 
@@ -489022,7 +489027,7 @@ async function exportProjectsCli(opts) {
489022
489027
  const outPath = import_path12.default.resolve(opts.outDir);
489023
489028
  const writeFile = async (fileName, content) => {
489024
489029
  if (typeof content === "string" && !opts.skipFormatting) {
489025
- content = await formatAsLocal(content, fileName, opts.outDir);
489030
+ content = await formatAsLocal(content, fileName);
489026
489031
  }
489027
489032
  const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
489028
489033
  await import_fs5.promises.mkdir(import_path12.default.join(outPath, projectName), { recursive: true });
@@ -489076,109 +489081,106 @@ async function exportProjectsCli(opts) {
489076
489081
  }
489077
489082
  };
489078
489083
  await Promise.all(result.map((res) => writeProj(res)));
489079
- await fixAllImportStatements(
489080
- {
489081
- configFile: "",
489082
- lockFile: "",
489083
- rootDir: import_path12.default.resolve(opts.outDir),
489084
- absoluteSrcDir: import_path12.default.resolve(opts.outDir),
489085
- config: {
489086
- platform: opts.platform || "react",
489087
- srcDir: "./",
489088
- defaultPlasmicDir: "./",
489089
- preserveJsImportExtensions: false,
489090
- code: {
489091
- lang: opts.codeLang || "ts",
489092
- scheme: "blackbox",
489093
- reactRuntime: "classic"
489094
- },
489095
- images: {
489096
- scheme: opts.imagesScheme || "files"
489097
- },
489098
- style: {
489099
- scheme: opts.styleScheme || "css-modules",
489100
- defaultStyleCssFilePath: ""
489101
- },
489102
- tokens: {},
489103
- globalVariants: {
489104
- variantGroups: result.flatMap((bundle) => {
489105
- const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
489106
- return bundle.globalVariants.map((gv) => ({
489107
- id: gv.id,
489108
- name: gv.name,
489109
- projectId: bundle.projectConfig.projectId,
489110
- contextFilePath: `./${projectName}/${gv.contextFileName}`
489111
- }));
489112
- })
489113
- },
489114
- projects: result.map((bundle) => {
489115
- var _a9;
489084
+ await fixAllImportStatements({
489085
+ configFile: "",
489086
+ lockFile: "",
489087
+ rootDir: import_path12.default.resolve(opts.outDir),
489088
+ absoluteSrcDir: import_path12.default.resolve(opts.outDir),
489089
+ config: {
489090
+ platform: opts.platform || "react",
489091
+ srcDir: "./",
489092
+ defaultPlasmicDir: "./",
489093
+ preserveJsImportExtensions: false,
489094
+ code: {
489095
+ lang: opts.codeLang || "ts",
489096
+ scheme: "blackbox",
489097
+ reactRuntime: "classic"
489098
+ },
489099
+ images: {
489100
+ scheme: opts.imagesScheme || "files"
489101
+ },
489102
+ style: {
489103
+ scheme: opts.styleScheme || "css-modules",
489104
+ defaultStyleCssFilePath: ""
489105
+ },
489106
+ tokens: {},
489107
+ globalVariants: {
489108
+ variantGroups: result.flatMap((bundle) => {
489116
489109
  const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
489117
- return {
489110
+ return bundle.globalVariants.map((gv) => ({
489111
+ id: gv.id,
489112
+ name: gv.name,
489118
489113
  projectId: bundle.projectConfig.projectId,
489119
- projectName: bundle.projectConfig.projectName,
489120
- version: "latest",
489121
- cssFilePath: `${projectName}/${bundle.projectConfig.cssFileName}`,
489122
- globalContextsFilePath: bundle.projectConfig.globalContextBundle ? `${projectName}/${DEFAULT_GLOBAL_CONTEXTS_NAME}.${extx}` : "",
489123
- splitsProviderFilePath: bundle.projectConfig.splitsProviderBundle ? `${projectName}/${DEFAULT_SPLITS_PROVIDER_NAME}.${extx}` : "",
489124
- styleTokensProviderFilePath: bundle.projectConfig.styleTokensProviderBundle ? `${projectName}/${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.${extx}` : "",
489125
- dataTokensFilePath: bundle.projectConfig.dataTokensBundle ? `${projectName}/${DEFAULT_DATA_TOKENS_NAME}.${opts.codeLang}` : "",
489126
- projectModuleFilePath: bundle.projectConfig.projectModuleBundle ? `${projectName}/${DEFAULT_PROJECT_MODULE_NAME}.${extx}` : "",
489127
- components: bundle.components.map((comp) => ({
489128
- id: comp.id,
489129
- name: comp.componentName,
489130
- projectId: bundle.projectConfig.projectId,
489131
- type: "managed",
489132
- importSpec: {
489133
- modulePath: `${projectName}/${comp.skeletonModuleFileName}`
489134
- },
489135
- renderModuleFilePath: `${projectName}/${comp.skeletonModuleFileName}`,
489136
- cssFilePath: `${projectName}/${comp.cssFileName}`,
489137
- scheme: "blackbox",
489138
- componentType: `${comp.isPage ? "page" : "component"}`,
489139
- plumeType: comp.plumeType
489140
- })),
489141
- codeComponents: bundle.codeComponentMetas.map((comp) => ({
489142
- id: comp.id,
489143
- name: comp.name,
489144
- displayName: comp.displayName,
489145
- componentImportPath: comp.importPath,
489146
- helper: comp.helper
489147
- })),
489148
- customFunctionMetas: ((_a9 = bundle.customFunctionMetas) != null ? _a9 : []).map(
489149
- (meta) => {
489150
- var _a10;
489151
- return {
489152
- id: meta.id,
489153
- name: meta.name,
489154
- importPath: meta.importPath,
489155
- defaultExport: meta.defaultExport,
489156
- namespace: (_a10 = meta.namespace) != null ? _a10 : null
489157
- };
489158
- }
489159
- ),
489160
- icons: bundle.iconAssets.map((icon) => ({
489161
- id: icon.id,
489162
- name: icon.name,
489163
- moduleFilePath: `${projectName}/${icon.fileName}`
489164
- })),
489165
- images: bundle.imageAssets.map((image) => ({
489166
- id: image.id,
489167
- name: image.name,
489168
- filePath: `${projectName}/${image.fileName}`
489169
- })),
489170
- indirect: false
489171
- };
489172
- }),
489173
- wrapPagesWithGlobalContexts: true
489114
+ contextFilePath: `./${projectName}/${gv.contextFileName}`
489115
+ }));
489116
+ })
489174
489117
  },
489175
- lock: {},
489176
- auth: {},
489177
- api,
489178
- cliArgs: {}
489118
+ projects: result.map((bundle) => {
489119
+ var _a9;
489120
+ const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
489121
+ return {
489122
+ projectId: bundle.projectConfig.projectId,
489123
+ projectName: bundle.projectConfig.projectName,
489124
+ version: "latest",
489125
+ cssFilePath: `${projectName}/${bundle.projectConfig.cssFileName}`,
489126
+ globalContextsFilePath: bundle.projectConfig.globalContextBundle ? `${projectName}/${DEFAULT_GLOBAL_CONTEXTS_NAME}.${extx}` : "",
489127
+ splitsProviderFilePath: bundle.projectConfig.splitsProviderBundle ? `${projectName}/${DEFAULT_SPLITS_PROVIDER_NAME}.${extx}` : "",
489128
+ styleTokensProviderFilePath: bundle.projectConfig.styleTokensProviderBundle ? `${projectName}/${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.${extx}` : "",
489129
+ dataTokensFilePath: bundle.projectConfig.dataTokensBundle ? `${projectName}/${DEFAULT_DATA_TOKENS_NAME}.${opts.codeLang}` : "",
489130
+ projectModuleFilePath: bundle.projectConfig.projectModuleBundle ? `${projectName}/${DEFAULT_PROJECT_MODULE_NAME}.${extx}` : "",
489131
+ components: bundle.components.map((comp) => ({
489132
+ id: comp.id,
489133
+ name: comp.componentName,
489134
+ projectId: bundle.projectConfig.projectId,
489135
+ type: "managed",
489136
+ importSpec: {
489137
+ modulePath: `${projectName}/${comp.skeletonModuleFileName}`
489138
+ },
489139
+ renderModuleFilePath: `${projectName}/${comp.skeletonModuleFileName}`,
489140
+ cssFilePath: `${projectName}/${comp.cssFileName}`,
489141
+ scheme: "blackbox",
489142
+ componentType: `${comp.isPage ? "page" : "component"}`,
489143
+ plumeType: comp.plumeType
489144
+ })),
489145
+ codeComponents: bundle.codeComponentMetas.map((comp) => ({
489146
+ id: comp.id,
489147
+ name: comp.name,
489148
+ displayName: comp.displayName,
489149
+ componentImportPath: comp.importPath,
489150
+ helper: comp.helper
489151
+ })),
489152
+ customFunctionMetas: ((_a9 = bundle.customFunctionMetas) != null ? _a9 : []).map(
489153
+ (meta) => {
489154
+ var _a10;
489155
+ return {
489156
+ id: meta.id,
489157
+ name: meta.name,
489158
+ importPath: meta.importPath,
489159
+ defaultExport: meta.defaultExport,
489160
+ namespace: (_a10 = meta.namespace) != null ? _a10 : null
489161
+ };
489162
+ }
489163
+ ),
489164
+ icons: bundle.iconAssets.map((icon) => ({
489165
+ id: icon.id,
489166
+ name: icon.name,
489167
+ moduleFilePath: `${projectName}/${icon.fileName}`
489168
+ })),
489169
+ images: bundle.imageAssets.map((image) => ({
489170
+ id: image.id,
489171
+ name: image.name,
489172
+ filePath: `${projectName}/${image.fileName}`
489173
+ })),
489174
+ indirect: false
489175
+ };
489176
+ }),
489177
+ wrapPagesWithGlobalContexts: true
489179
489178
  },
489180
- opts.outDir
489181
- );
489179
+ lock: {},
489180
+ auth: {},
489181
+ api,
489182
+ cliArgs: {}
489183
+ });
489182
489184
  }
489183
489185
  async function exportProjects(api, opts) {
489184
489186
  var _a8;
@@ -489233,53 +489235,46 @@ async function exportProjects(api, opts) {
489233
489235
  for (const comp of proj.components) {
489234
489236
  [comp.skeletonModuleFileName, comp.skeletonModule] = await maybeConvertTsxToJsx(
489235
489237
  comp.skeletonModuleFileName,
489236
- comp.skeletonModule,
489237
- "."
489238
+ comp.skeletonModule
489238
489239
  );
489239
489240
  }
489240
489241
  for (const icon of proj.iconAssets) {
489241
489242
  [icon.fileName, icon.module] = await maybeConvertTsxToJsx(
489242
489243
  icon.fileName,
489243
- icon.module,
489244
- "."
489244
+ icon.module
489245
489245
  );
489246
489246
  }
489247
489247
  for (const gv of proj.globalVariants) {
489248
489248
  [gv.contextFileName, gv.contextModule] = await maybeConvertTsxToJsx(
489249
489249
  gv.contextFileName,
489250
- gv.contextModule,
489251
- "."
489250
+ gv.contextModule
489252
489251
  );
489253
489252
  }
489254
489253
  if (proj.projectConfig.globalContextBundle) {
489255
489254
  const res = await maybeConvertTsxToJsx(
489256
489255
  `${DEFAULT_GLOBAL_CONTEXTS_NAME}.tsx`,
489257
- proj.projectConfig.globalContextBundle.contextModule,
489258
- "."
489256
+ proj.projectConfig.globalContextBundle.contextModule
489259
489257
  );
489260
489258
  proj.projectConfig.globalContextBundle.contextModule = res[1];
489261
489259
  }
489262
489260
  if (proj.projectConfig.splitsProviderBundle) {
489263
489261
  const res = await maybeConvertTsxToJsx(
489264
489262
  `${DEFAULT_SPLITS_PROVIDER_NAME}.tsx`,
489265
- proj.projectConfig.splitsProviderBundle.module,
489266
- "."
489263
+ proj.projectConfig.splitsProviderBundle.module
489267
489264
  );
489268
489265
  proj.projectConfig.splitsProviderBundle.module = res[1];
489269
489266
  }
489270
489267
  if (proj.projectConfig.styleTokensProviderBundle) {
489271
489268
  const res = await maybeConvertTsxToJsx(
489272
489269
  `${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.tsx`,
489273
- proj.projectConfig.styleTokensProviderBundle.module,
489274
- "."
489270
+ proj.projectConfig.styleTokensProviderBundle.module
489275
489271
  );
489276
489272
  proj.projectConfig.styleTokensProviderBundle.module = res[1];
489277
489273
  }
489278
489274
  if (proj.projectConfig.projectModuleBundle) {
489279
489275
  const res = await maybeConvertTsxToJsx(
489280
489276
  `${DEFAULT_PROJECT_MODULE_NAME}.tsx`,
489281
- proj.projectConfig.projectModuleBundle.module,
489282
- "."
489277
+ proj.projectConfig.projectModuleBundle.module
489283
489278
  );
489284
489279
  proj.projectConfig.projectModuleBundle.module = res[1];
489285
489280
  }
@@ -489291,14 +489286,15 @@ async function exportProjects(api, opts) {
489291
489286
  // src/actions/fix-imports.ts
489292
489287
  init_import_meta_url();
489293
489288
  async function fixImports(opts) {
489294
- if (!opts.baseDir)
489289
+ if (!opts.baseDir) {
489295
489290
  opts.baseDir = process.cwd();
489291
+ }
489296
489292
  if (opts.skipFormatting) {
489297
489293
  GLOBAL_SETTINGS.skipFormatting = true;
489298
489294
  }
489299
489295
  const context = await getContext(opts, { enableSkipAuth: true });
489300
- await updateConfig(context, context.config, opts.baseDir);
489301
- await fixAllImportStatements(context, opts.baseDir);
489296
+ await updateConfig(context, context.config);
489297
+ await fixAllImportStatements(context);
489302
489298
  }
489303
489299
 
489304
489300
  // src/actions/info.ts
@@ -489823,30 +489819,43 @@ async function syncRscFiles(context, project, bundle, compConfig, opts) {
489823
489819
  clientModulePath: ""
489824
489820
  };
489825
489821
  }
489826
- const serverModuleFilePath = defaultResourcePath(
489822
+ let serverModuleFilePath = defaultResourcePath(
489827
489823
  context,
489828
489824
  project,
489829
489825
  rscMetadata.pageWrappers.server.fileName
489830
489826
  );
489827
+ let serverModuleContent = rscMetadata.pageWrappers.server.module;
489828
+ if (context.config.code.lang === "js") {
489829
+ const [convertedFileName, convertedContent] = await maybeConvertTsxToJsx(
489830
+ serverModuleFilePath,
489831
+ serverModuleContent
489832
+ );
489833
+ serverModuleFilePath = convertedFileName;
489834
+ serverModuleContent = convertedContent;
489835
+ }
489831
489836
  compConfig.rsc.serverModulePath = serverModuleFilePath;
489832
- await writeFileContent(
489833
- context,
489834
- serverModuleFilePath,
489835
- rscMetadata.pageWrappers.server.module,
489836
- {
489837
- force: true
489838
- }
489839
- );
489840
- const clientModuleFilePath = compConfig.importSpec.modulePath.replace(
489841
- /\.tsx$/,
489837
+ await writeFileContent(context, serverModuleFilePath, serverModuleContent, {
489838
+ force: true
489839
+ });
489840
+ let clientModuleFilePath = compConfig.importSpec.modulePath.replace(
489841
+ /\.(tsx|jsx)$/,
489842
489842
  "-client.tsx"
489843
489843
  );
489844
+ let clientModuleContent = rscMetadata.pageWrappers.client.module;
489845
+ if (context.config.code.lang === "js") {
489846
+ const [convertedFileName, convertedContent] = await maybeConvertTsxToJsx(
489847
+ clientModuleFilePath,
489848
+ clientModuleContent
489849
+ );
489850
+ clientModuleFilePath = convertedFileName;
489851
+ clientModuleContent = convertedContent;
489852
+ }
489844
489853
  compConfig.rsc.clientModulePath = clientModuleFilePath;
489845
489854
  if (opts.shouldRegenerate) {
489846
489855
  await writeFileContent(
489847
489856
  context,
489848
489857
  clientModuleFilePath,
489849
- rscMetadata.pageWrappers.client.module,
489858
+ clientModuleContent,
489850
489859
  {
489851
489860
  force: false
489852
489861
  }
@@ -489856,7 +489865,7 @@ async function syncRscFiles(context, project, bundle, compConfig, opts) {
489856
489865
  }
489857
489866
 
489858
489867
  // src/actions/sync-components.ts
489859
- async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir) {
489868
+ async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums) {
489860
489869
  var _a8;
489861
489870
  const componentsFromChecksums = /* @__PURE__ */ new Set([
489862
489871
  ...checksums.cssRulesChecksums.map(([id2, _7]) => id2),
@@ -489920,7 +489929,6 @@ async function syncProjectComponents(context, project, version, componentBundles
489920
489929
  componentName,
489921
489930
  id: id2,
489922
489931
  scheme,
489923
- nameInIdToUuid,
489924
489932
  isPage,
489925
489933
  path: pagePath,
489926
489934
  plumeType
@@ -489966,7 +489974,6 @@ async function syncProjectComponents(context, project, version, componentBundles
489966
489974
  await writeFileContent(context, skeletonPath, skeletonModule, {
489967
489975
  force: false
489968
489976
  });
489969
- } else if (compConfig.type === "mapped") {
489970
489977
  } else if (compConfig.type === "managed") {
489971
489978
  compConfig.componentType = isPage ? "page" : "component";
489972
489979
  let editedFile;
@@ -490087,8 +490094,7 @@ async function syncProjectComponents(context, project, version, componentBundles
490087
490094
  );
490088
490095
  const formattedCssRules = await formatAsLocal(
490089
490096
  cssRules,
490090
- compConfig.cssFilePath,
490091
- baseDir
490097
+ compConfig.cssFilePath
490092
490098
  );
490093
490099
  await writeFileContent(
490094
490100
  context,
@@ -490110,7 +490116,7 @@ async function syncProjectComponents(context, project, version, componentBundles
490110
490116
  init_import_meta_url();
490111
490117
  var import_lodash20 = __toESM(require_lodash());
490112
490118
  var import_upath10 = __toESM(require_upath());
490113
- async function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName, baseDir) {
490119
+ async function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName) {
490114
490120
  const projectId = projectMeta.projectId;
490115
490121
  const projectLock = getOrAddProjectLock(context, projectId, branchName);
490116
490122
  const existingVariantConfigs = import_lodash20.default.keyBy(
@@ -490183,11 +490189,7 @@ async function syncGlobalVariants(context, projectMeta, bundles, checksums, bran
490183
490189
  await writeFileContent(
490184
490190
  context,
490185
490191
  variantConfig.contextFilePath,
490186
- await formatAsLocal(
490187
- bundle.contextModule,
490188
- variantConfig.contextFilePath,
490189
- baseDir
490190
- ),
490192
+ await formatAsLocal(bundle.contextModule, variantConfig.contextFilePath),
490191
490193
  { force: !isNew }
490192
490194
  );
490193
490195
  }
@@ -490215,7 +490217,7 @@ async function syncGlobalVariants(context, projectMeta, bundles, checksums, bran
490215
490217
  init_import_meta_url();
490216
490218
  var import_lodash21 = __toESM(require_lodash());
490217
490219
  var import_upath11 = __toESM(require_upath());
490218
- async function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums, baseDir) {
490220
+ async function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums) {
490219
490221
  const project = getOrAddProjectConfig(context, projectId);
490220
490222
  if (!project.icons) {
490221
490223
  project.icons = [];
@@ -490284,7 +490286,7 @@ async function syncProjectIconAssets(context, projectId, branchName, version, ic
490284
490286
  await writeFileContent(
490285
490287
  context,
490286
490288
  iconConfig.moduleFilePath,
490287
- await formatAsLocal(bundle.module, iconConfig.moduleFilePath, baseDir),
490289
+ await formatAsLocal(bundle.module, iconConfig.moduleFilePath),
490288
490290
  {
490289
490291
  force: !isNew
490290
490292
  }
@@ -490574,7 +490576,7 @@ async function sync(opts, metadataDefaults) {
490574
490576
  }
490575
490577
  });
490576
490578
  }
490577
- await fixAllImportStatements(context, opts.baseDir, summary);
490579
+ await fixAllImportStatements(context, summary);
490578
490580
  const codegenVersion = await context.api.latestCodegenVersion();
490579
490581
  context.lock.projects.forEach((p5) => {
490580
490582
  if (projectsToSync.some(
@@ -490583,7 +490585,7 @@ async function sync(opts, metadataDefaults) {
490583
490585
  p5.codegenVersion = codegenVersion;
490584
490586
  }
490585
490587
  });
490586
- await updateConfig(context, context.config, baseDir);
490588
+ await updateConfig(context, context.config);
490587
490589
  };
490588
490590
  if (opts.skipBuffering) {
490589
490591
  await doSync();
@@ -490733,27 +490735,23 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
490733
490735
  for (const c5 of projectBundle.components) {
490734
490736
  [c5.renderModuleFileName, c5.renderModule] = await maybeConvertTsxToJsx(
490735
490737
  c5.renderModuleFileName,
490736
- c5.renderModule,
490737
- opts.baseDir
490738
+ c5.renderModule
490738
490739
  );
490739
490740
  [c5.skeletonModuleFileName, c5.skeletonModule] = await maybeConvertTsxToJsx(
490740
490741
  c5.skeletonModuleFileName,
490741
- c5.skeletonModule,
490742
- opts.baseDir
490742
+ c5.skeletonModule
490743
490743
  );
490744
490744
  }
490745
490745
  for (const icon of projectBundle.iconAssets) {
490746
490746
  [icon.fileName, icon.module] = await maybeConvertTsxToJsx(
490747
490747
  icon.fileName,
490748
- icon.module,
490749
- opts.baseDir
490748
+ icon.module
490750
490749
  );
490751
490750
  }
490752
490751
  for (const gv of projectBundle.globalVariants) {
490753
490752
  [gv.contextFileName, gv.contextModule] = await maybeConvertTsxToJsx(
490754
490753
  gv.contextFileName,
490755
- gv.contextModule,
490756
- opts.baseDir
490754
+ gv.contextModule
490757
490755
  );
490758
490756
  }
490759
490757
  }
@@ -490762,8 +490760,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
490762
490760
  projectBundle.projectConfig,
490763
490761
  projectBundle.globalVariants,
490764
490762
  projectBundle.checksums,
490765
- branchName,
490766
- opts.baseDir
490763
+ branchName
490767
490764
  );
490768
490765
  await syncProjectConfig(
490769
490766
  context,
@@ -490776,7 +490773,6 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
490776
490773
  opts.forceOverwrite,
490777
490774
  summary,
490778
490775
  projectBundle.checksums,
490779
- opts.baseDir,
490780
490776
  indirect
490781
490777
  );
490782
490778
  syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
@@ -490796,8 +490792,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
490796
490792
  branchName,
490797
490793
  projectVersion,
490798
490794
  projectBundle.iconAssets,
490799
- projectBundle.checksums,
490800
- opts.baseDir
490795
+ projectBundle.checksums
490801
490796
  );
490802
490797
  await syncProjectImageAssets(
490803
490798
  context,
@@ -490824,7 +490819,7 @@ async function syncStyleConfig(context, response) {
490824
490819
  force: true
490825
490820
  });
490826
490821
  }
490827
- async function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, summary, checksums, baseDir, indirect) {
490822
+ async function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, summary, checksums, indirect) {
490828
490823
  const defaultCssFilePath = defaultResourcePath(
490829
490824
  context,
490830
490825
  projectBundle.projectName,
@@ -490860,8 +490855,7 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
490860
490855
  if (projectBundle.cssRules) {
490861
490856
  const formattedCssRules = await formatAsLocal(
490862
490857
  projectBundle.cssRules,
490863
- projectConfig.cssFilePath,
490864
- baseDir
490858
+ projectConfig.cssFilePath
490865
490859
  );
490866
490860
  await writeFileContent(
490867
490861
  context,
@@ -490885,40 +490879,35 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
490885
490879
  projectBundle,
490886
490880
  projectConfig,
490887
490881
  projectLock,
490888
- checksums,
490889
- baseDir
490882
+ checksums
490890
490883
  );
490891
490884
  await syncSplitsProvider(
490892
490885
  context,
490893
490886
  projectBundle,
490894
490887
  projectConfig,
490895
490888
  projectLock,
490896
- checksums,
490897
- baseDir
490889
+ checksums
490898
490890
  );
490899
490891
  await syncProjectModule(
490900
490892
  context,
490901
490893
  projectBundle,
490902
490894
  projectConfig,
490903
490895
  projectLock,
490904
- checksums,
490905
- baseDir
490896
+ checksums
490906
490897
  );
490907
490898
  await syncStyleTokensProvider(
490908
490899
  context,
490909
490900
  projectBundle,
490910
490901
  projectConfig,
490911
490902
  projectLock,
490912
- checksums,
490913
- baseDir
490903
+ checksums
490914
490904
  );
490915
490905
  await syncDataTokens(
490916
490906
  context,
490917
490907
  projectBundle,
490918
490908
  projectConfig,
490919
490909
  projectLock,
490920
- checksums,
490921
- baseDir
490910
+ checksums
490922
490911
  );
490923
490912
  await syncProjectComponents(
490924
490913
  context,
@@ -490928,8 +490917,7 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
490928
490917
  forceOverwrite,
490929
490918
  summary,
490930
490919
  projectLock,
490931
- checksums,
490932
- baseDir
490920
+ checksums
490933
490921
  );
490934
490922
  }
490935
490923
  function syncCodeComponentsMeta(context, projectId, codeComponentBundles) {