@plasmicapp/cli 0.1.353 → 0.1.355

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