@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/lib.js CHANGED
@@ -469785,7 +469785,7 @@ var require_src5 = __commonJS2({
469785
469785
  Object.defineProperty(exports, "__esModule", { value: true });
469786
469786
  var fs42 = __importStar7(__require("fs"));
469787
469787
  var path142 = __importStar7(__require("path"));
469788
- var semver3 = {
469788
+ var semver4 = {
469789
469789
  gte: require_gte2()
469790
469790
  };
469791
469791
  var fnmatch_1 = __importDefault7(require_fnmatch());
@@ -469814,7 +469814,7 @@ var require_src5 = __commonJS2({
469814
469814
  return paths;
469815
469815
  }
469816
469816
  function processMatches(matches, version) {
469817
- if ("indent_style" in matches && matches.indent_style === "tab" && !("indent_size" in matches) && semver3.gte(version, "0.10.0")) {
469817
+ if ("indent_style" in matches && matches.indent_style === "tab" && !("indent_size" in matches) && semver4.gte(version, "0.10.0")) {
469818
469818
  matches.indent_size = "tab";
469819
469819
  }
469820
469820
  if ("indent_size" in matches && !("tab_width" in matches) && matches.indent_size !== "tab") {
@@ -480692,7 +480692,7 @@ init_import_meta_url();
480692
480692
  var import_lodash = __toESM(require_lodash());
480693
480693
  var MODULE_NAME = "plasmic-data-tokens";
480694
480694
  var DEFAULT_DATA_TOKENS_NAME = MODULE_NAME;
480695
- async function syncDataTokens(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
480695
+ async function syncDataTokens(context, projectMeta, projectConfig, projectLock, checksums) {
480696
480696
  const resourcePath = getDataTokensResourcePath(context, projectConfig);
480697
480697
  if (checksums.dataTokensChecksum && projectMeta.dataTokensBundle) {
480698
480698
  if (context.cliArgs.quiet !== true) {
@@ -480702,8 +480702,7 @@ async function syncDataTokens(context, projectMeta, projectConfig, projectLock,
480702
480702
  }
480703
480703
  if (context.config.code.lang === "js") {
480704
480704
  projectMeta.dataTokensBundle.module = await formatScript(
480705
- tsxToJsx(projectMeta.dataTokensBundle.module),
480706
- baseDir
480705
+ tsxToJsx(projectMeta.dataTokensBundle.module)
480707
480706
  );
480708
480707
  }
480709
480708
  writeFileContent(
@@ -480754,7 +480753,7 @@ init_import_meta_url();
480754
480753
  var import_lodash2 = __toESM(require_lodash());
480755
480754
  var COMPONENT_NAME = "PlasmicGlobalContextsProvider";
480756
480755
  var DEFAULT_GLOBAL_CONTEXTS_NAME = COMPONENT_NAME;
480757
- async function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
480756
+ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLock, checksums) {
480758
480757
  const resourcePath = getGlobalContextsResourcePath(context, projectConfig);
480759
480758
  if (checksums.globalContextsChecksum && projectMeta.globalContextBundle) {
480760
480759
  if (context.cliArgs.quiet !== true) {
@@ -480764,8 +480763,7 @@ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLo
480764
480763
  }
480765
480764
  if (context.config.code.lang === "js") {
480766
480765
  projectMeta.globalContextBundle.contextModule = await formatScript(
480767
- tsxToJsx(projectMeta.globalContextBundle.contextModule),
480768
- baseDir
480766
+ tsxToJsx(projectMeta.globalContextBundle.contextModule)
480769
480767
  );
480770
480768
  }
480771
480769
  await writeFileContent(
@@ -480776,7 +480774,7 @@ async function syncGlobalContexts(context, projectMeta, projectConfig, projectLo
480776
480774
  );
480777
480775
  projectConfig.globalContextsFilePath = resourcePath;
480778
480776
  const fl5 = projectLock.fileLocks.find(
480779
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "globalContexts"
480777
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "globalContexts"
480780
480778
  );
480781
480779
  if (fl5) {
480782
480780
  fl5.checksum = checksums.globalContextsChecksum;
@@ -481019,7 +481017,7 @@ init_import_meta_url();
481019
481017
  var import_lodash5 = __toESM(require_lodash());
481020
481018
  var MODULE_NAME2 = "plasmic";
481021
481019
  var DEFAULT_PROJECT_MODULE_NAME = MODULE_NAME2;
481022
- async function syncProjectModule(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
481020
+ async function syncProjectModule(context, projectMeta, projectConfig, projectLock, checksums) {
481023
481021
  const resourcePath = getProjectModuleResourcePath(context, projectConfig);
481024
481022
  if (checksums.projectModuleChecksum && projectMeta.projectModuleBundle) {
481025
481023
  if (context.cliArgs.quiet !== true) {
@@ -481029,8 +481027,7 @@ async function syncProjectModule(context, projectMeta, projectConfig, projectLoc
481029
481027
  }
481030
481028
  if (context.config.code.lang === "js") {
481031
481029
  projectMeta.projectModuleBundle.module = await formatScript(
481032
- tsxToJsx(projectMeta.projectModuleBundle.module),
481033
- baseDir
481030
+ tsxToJsx(projectMeta.projectModuleBundle.module)
481034
481031
  );
481035
481032
  }
481036
481033
  await writeFileContent(
@@ -481041,7 +481038,7 @@ async function syncProjectModule(context, projectMeta, projectConfig, projectLoc
481041
481038
  );
481042
481039
  projectConfig.projectModuleFilePath = resourcePath;
481043
481040
  const fl5 = projectLock.fileLocks.find(
481044
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "projectModule"
481041
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "projectModule"
481045
481042
  );
481046
481043
  if (fl5) {
481047
481044
  fl5.checksum = checksums.projectModuleChecksum || "";
@@ -481076,7 +481073,7 @@ init_import_meta_url();
481076
481073
  var import_lodash6 = __toESM(require_lodash());
481077
481074
  var COMPONENT_NAME2 = "PlasmicSplitsProvider";
481078
481075
  var DEFAULT_SPLITS_PROVIDER_NAME = COMPONENT_NAME2;
481079
- async function syncSplitsProvider(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
481076
+ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLock, checksums) {
481080
481077
  const resourcePath = getSplitsProviderResourcePath(context, projectConfig);
481081
481078
  if (checksums.splitsProviderChecksum && projectMeta.splitsProviderBundle) {
481082
481079
  if (context.cliArgs.quiet !== true) {
@@ -481086,8 +481083,7 @@ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLo
481086
481083
  }
481087
481084
  if (context.config.code.lang === "js") {
481088
481085
  projectMeta.splitsProviderBundle.module = await formatScript(
481089
- tsxToJsx(projectMeta.splitsProviderBundle.module),
481090
- baseDir
481086
+ tsxToJsx(projectMeta.splitsProviderBundle.module)
481091
481087
  );
481092
481088
  }
481093
481089
  await writeFileContent(
@@ -481098,7 +481094,7 @@ async function syncSplitsProvider(context, projectMeta, projectConfig, projectLo
481098
481094
  );
481099
481095
  projectConfig.splitsProviderFilePath = resourcePath;
481100
481096
  const fl5 = projectLock.fileLocks.find(
481101
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "splitsProvider"
481097
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "splitsProvider"
481102
481098
  );
481103
481099
  if (fl5) {
481104
481100
  fl5.checksum = checksums.splitsProviderChecksum;
@@ -481133,7 +481129,7 @@ init_import_meta_url();
481133
481129
  var import_lodash7 = __toESM(require_lodash());
481134
481130
  var MODULE_NAME3 = "PlasmicStyleTokensProvider";
481135
481131
  var DEFAULT_STYLE_TOKENS_PROVIDER_NAME = MODULE_NAME3;
481136
- async function syncStyleTokensProvider(context, projectMeta, projectConfig, projectLock, checksums, baseDir) {
481132
+ async function syncStyleTokensProvider(context, projectMeta, projectConfig, projectLock, checksums) {
481137
481133
  const resourcePath = getStyleTokensProviderResourcePath(
481138
481134
  context,
481139
481135
  projectConfig
@@ -481146,8 +481142,7 @@ async function syncStyleTokensProvider(context, projectMeta, projectConfig, proj
481146
481142
  }
481147
481143
  if (context.config.code.lang === "js") {
481148
481144
  projectMeta.styleTokensProviderBundle.module = await formatScript(
481149
- tsxToJsx(projectMeta.styleTokensProviderBundle.module),
481150
- baseDir
481145
+ tsxToJsx(projectMeta.styleTokensProviderBundle.module)
481151
481146
  );
481152
481147
  }
481153
481148
  writeFileContent(
@@ -481158,7 +481153,7 @@ async function syncStyleTokensProvider(context, projectMeta, projectConfig, proj
481158
481153
  );
481159
481154
  projectConfig.styleTokensProviderFilePath = resourcePath;
481160
481155
  const fl5 = projectLock.fileLocks.find(
481161
- (fl6) => fl6.assetId === projectConfig.projectId && fl6.type === "styleTokensProvider"
481156
+ (fileLock) => fileLock.assetId === projectConfig.projectId && fileLock.type === "styleTokensProvider"
481162
481157
  );
481163
481158
  if (fl5) {
481164
481159
  fl5.checksum = checksums.styleTokensProviderChecksum || "";
@@ -481195,7 +481190,7 @@ var GLOBAL_SETTINGS = {
481195
481190
  };
481196
481191
 
481197
481192
  // src/utils/code-utils.ts
481198
- async function formatAsLocal(content, filePath, baseDir, defaultOpts) {
481193
+ async function formatAsLocal(content, filePath, defaultOpts) {
481199
481194
  if (GLOBAL_SETTINGS.skipFormatting) {
481200
481195
  return content;
481201
481196
  }
@@ -481209,12 +481204,12 @@ async function formatAsLocal(content, filePath, baseDir, defaultOpts) {
481209
481204
  const res2 = await format2(res, opts);
481210
481205
  return res2;
481211
481206
  }
481212
- async function nodeToFormattedCode(n26, baseDir, unformatted, commentsToRemove) {
481207
+ async function nodeToFormattedCode(n26, unformatted, commentsToRemove) {
481213
481208
  const c5 = (0, import_generator.default)(n26, {
481214
481209
  retainLines: true,
481215
481210
  shouldPrintComment: (comment) => !commentsToRemove || !commentsToRemove.has(comment)
481216
481211
  }).code;
481217
- return unformatted ? c5 : await formatAsLocal(c5, "/tmp/x.tsx", baseDir, {
481212
+ return unformatted ? c5 : await formatAsLocal(c5, "/tmp/x.tsx", {
481218
481213
  arrowParens: "avoid"
481219
481214
  });
481220
481215
  }
@@ -481302,7 +481297,7 @@ function filterUnformattedMarker(code, changed) {
481302
481297
  code = lines.filter((line3) => !isUnformattedMarker(line3)).join("\n");
481303
481298
  return [code, changed];
481304
481299
  }
481305
- async function replaceImports(context, code, fromPath, fixImportContext, removeImportDirective, baseDir, changed = false) {
481300
+ async function replaceImports(context, code, fromPath, fixImportContext, removeImportDirective, changed = false) {
481306
481301
  [code, changed] = filterUnformattedMarker(code, changed);
481307
481302
  const file = parser.parse(code, {
481308
481303
  strictMode: true,
@@ -481546,7 +481541,7 @@ async function replaceImports(context, code, fromPath, fixImportContext, removeI
481546
481541
  if (!changed) {
481547
481542
  return code;
481548
481543
  }
481549
- return nodeToFormattedCode(file, baseDir, !changed, commentsToRemove);
481544
+ return nodeToFormattedCode(file, !changed, commentsToRemove);
481550
481545
  }
481551
481546
  function throwMissingReference(context, itemType, uuid, fromPath) {
481552
481547
  let recFix = `Please make sure projects that "${uuid}" depends on have already been synced.`;
@@ -481627,7 +481622,7 @@ var mkFixImportContext = (config) => {
481627
481622
  projects
481628
481623
  };
481629
481624
  };
481630
- async function fixAllImportStatements(context, baseDir, summary) {
481625
+ async function fixAllImportStatements(context, summary) {
481631
481626
  logger.info("Fixing import statements...");
481632
481627
  const config = context.config;
481633
481628
  const fixImportContext = mkFixImportContext(config);
@@ -481635,12 +481630,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
481635
481630
  for (const project of config.projects) {
481636
481631
  for (const compConfig of project.components) {
481637
481632
  try {
481638
- await fixRscModulesImports(
481639
- context,
481640
- baseDir,
481641
- fixImportContext,
481642
- compConfig
481643
- );
481633
+ await fixRscModulesImports(context, fixImportContext, compConfig);
481644
481634
  } catch (err) {
481645
481635
  lastError = err;
481646
481636
  }
@@ -481655,8 +481645,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
481655
481645
  context,
481656
481646
  compConfig,
481657
481647
  fixImportContext,
481658
- fixSkeletonModule,
481659
- baseDir
481648
+ fixSkeletonModule
481660
481649
  );
481661
481650
  } catch (err) {
481662
481651
  logger.error(
@@ -481668,7 +481657,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
481668
481657
  }
481669
481658
  }
481670
481659
  try {
481671
- await fixGlobalContextImportStatements(context, fixImportContext, baseDir);
481660
+ await fixGlobalContextImportStatements(context, fixImportContext);
481672
481661
  } catch (err) {
481673
481662
  logger.error(
481674
481663
  `Error encountered while fixing imports for global contexts: ${err}`
@@ -481679,7 +481668,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
481679
481668
  await fixImportStatements(
481680
481669
  context,
481681
481670
  fixImportContext,
481682
- baseDir,
481683
481671
  "splitsProviderFilePath",
481684
481672
  getSplitsProviderResourcePath
481685
481673
  );
@@ -481693,7 +481681,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
481693
481681
  await fixImportStatements(
481694
481682
  context,
481695
481683
  fixImportContext,
481696
- baseDir,
481697
481684
  "projectModuleFilePath",
481698
481685
  getProjectModuleResourcePath
481699
481686
  );
@@ -481707,7 +481694,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
481707
481694
  await fixImportStatements(
481708
481695
  context,
481709
481696
  fixImportContext,
481710
- baseDir,
481711
481697
  "styleTokensProviderFilePath",
481712
481698
  getStyleTokensProviderResourcePath
481713
481699
  );
@@ -481721,7 +481707,6 @@ async function fixAllImportStatements(context, baseDir, summary) {
481721
481707
  await fixImportStatements(
481722
481708
  context,
481723
481709
  fixImportContext,
481724
- baseDir,
481725
481710
  "dataTokensFilePath",
481726
481711
  getDataTokensResourcePath
481727
481712
  );
@@ -481735,14 +481720,13 @@ async function fixAllImportStatements(context, baseDir, summary) {
481735
481720
  throw lastError;
481736
481721
  }
481737
481722
  }
481738
- async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule, baseDir) {
481723
+ async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule) {
481739
481724
  if (compConfig.type !== "mapped" && isLocalModulePath(compConfig.importSpec.modulePath) && fixSkeletonModule) {
481740
481725
  await fixFileImportStatements(
481741
481726
  context,
481742
481727
  compConfig.importSpec.modulePath,
481743
481728
  fixImportContext,
481744
- true,
481745
- baseDir
481729
+ true
481746
481730
  );
481747
481731
  }
481748
481732
  let renderModuleChanged = false;
@@ -481765,11 +481749,10 @@ async function fixComponentImportStatements(context, compConfig, fixImportContex
481765
481749
  compConfig.renderModuleFilePath,
481766
481750
  fixImportContext,
481767
481751
  false,
481768
- baseDir,
481769
481752
  renderModuleChanged
481770
481753
  );
481771
481754
  }
481772
- async function fixFileImportStatements(context, srcDirFilePath, fixImportContext, removeImportDirective, baseDir, fileHasChanged = false) {
481755
+ async function fixFileImportStatements(context, srcDirFilePath, fixImportContext, removeImportDirective, fileHasChanged = false) {
481773
481756
  const filePath = makeFilePath(context, srcDirFilePath);
481774
481757
  if (!existsBuffered(filePath)) {
481775
481758
  logger.warn(
@@ -481784,7 +481767,6 @@ async function fixFileImportStatements(context, srcDirFilePath, fixImportContext
481784
481767
  srcDirFilePath,
481785
481768
  fixImportContext,
481786
481769
  removeImportDirective,
481787
- baseDir,
481788
481770
  fileHasChanged
481789
481771
  );
481790
481772
  if (prevContent !== newContent) {
@@ -481833,15 +481815,15 @@ var tsxToJsx = (code) => {
481833
481815
  });
481834
481816
  return fixPostTranspile(result.outputText);
481835
481817
  };
481836
- async function maybeConvertTsxToJsx(fileName, content, baseDir) {
481818
+ async function maybeConvertTsxToJsx(fileName, content) {
481837
481819
  if (fileName.endsWith("tsx")) {
481838
481820
  const jsFileName = stripExtension(fileName) + ".jsx";
481839
- const jsContent = await formatScript(tsxToJsx(content), baseDir);
481821
+ const jsContent = await formatScript(tsxToJsx(content));
481840
481822
  return [jsFileName, jsContent];
481841
481823
  }
481842
481824
  return [fileName, content];
481843
481825
  }
481844
- async function formatScript(code, baseDir) {
481826
+ async function formatScript(code) {
481845
481827
  const file = parser.parse(code, {
481846
481828
  strictMode: true,
481847
481829
  sourceType: "module",
@@ -481859,18 +481841,18 @@ async function formatScript(code, baseDir) {
481859
481841
  }
481860
481842
  }
481861
481843
  });
481862
- const withmarkers = await nodeToFormattedCode(file, baseDir, true);
481844
+ const withmarkers = await nodeToFormattedCode(file, true);
481863
481845
  const withNewLines = withmarkers.replace(
481864
481846
  new RegExp(`"${newLineMarker}"`, "g"),
481865
481847
  "\n"
481866
481848
  );
481867
- return await formatAsLocal(withNewLines, "/tmp/x.tsx", baseDir, {
481849
+ return await formatAsLocal(withNewLines, "/tmp/x.tsx", {
481868
481850
  printWidth: 80,
481869
481851
  tabWidth: 2,
481870
481852
  useTabs: false
481871
481853
  });
481872
481854
  }
481873
- async function fixGlobalContextImportStatements(context, fixImportContext, baseDir) {
481855
+ async function fixGlobalContextImportStatements(context, fixImportContext) {
481874
481856
  for (const project of context.config.projects) {
481875
481857
  if (!project.globalContextsFilePath) {
481876
481858
  continue;
@@ -481893,7 +481875,6 @@ async function fixGlobalContextImportStatements(context, fixImportContext, baseD
481893
481875
  resourcePath,
481894
481876
  fixImportContext,
481895
481877
  false,
481896
- baseDir,
481897
481878
  true
481898
481879
  );
481899
481880
  if (prevContent !== newContent) {
@@ -481903,7 +481884,7 @@ async function fixGlobalContextImportStatements(context, fixImportContext, baseD
481903
481884
  }
481904
481885
  }
481905
481886
  }
481906
- async function fixImportStatements(context, fixImportContext, baseDir, configKey, getResourcePath) {
481887
+ async function fixImportStatements(context, fixImportContext, configKey, getResourcePath) {
481907
481888
  for (const project of context.config.projects) {
481908
481889
  if (!project[configKey]) {
481909
481890
  continue;
@@ -481926,7 +481907,6 @@ async function fixImportStatements(context, fixImportContext, baseDir, configKey
481926
481907
  resourcePath,
481927
481908
  fixImportContext,
481928
481909
  false,
481929
- baseDir,
481930
481910
  true
481931
481911
  );
481932
481912
  if (prevContent !== newContent) {
@@ -481936,7 +481916,7 @@ async function fixImportStatements(context, fixImportContext, baseDir, configKey
481936
481916
  }
481937
481917
  }
481938
481918
  }
481939
- async function fixRscModulesImports(context, baseDir, fixImportContext, compConfig) {
481919
+ async function fixRscModulesImports(context, fixImportContext, compConfig) {
481940
481920
  var _a8, _b2;
481941
481921
  const errors = [];
481942
481922
  for (const modulePath of [
@@ -481951,8 +481931,7 @@ async function fixRscModulesImports(context, baseDir, fixImportContext, compConf
481951
481931
  context,
481952
481932
  modulePath,
481953
481933
  fixImportContext,
481954
- false,
481955
- baseDir
481934
+ false
481956
481935
  );
481957
481936
  } catch (err) {
481958
481937
  logger.error(
@@ -482648,7 +482627,7 @@ function readConfig(configFile, autoFillDefaults) {
482648
482627
  throw e7;
482649
482628
  }
482650
482629
  }
482651
- async function writeConfig(configFile, config, baseDir) {
482630
+ async function writeConfig(configFile, config) {
482652
482631
  await writeFileContentRaw(
482653
482632
  configFile,
482654
482633
  await formatAsLocal(
@@ -482660,31 +482639,26 @@ async function writeConfig(configFile, config, baseDir) {
482660
482639
  void 0,
482661
482640
  2
482662
482641
  ),
482663
- configFile,
482664
- baseDir
482642
+ configFile
482665
482643
  ),
482666
482644
  {
482667
482645
  force: true
482668
482646
  }
482669
482647
  );
482670
482648
  }
482671
- async function writeLock(lockFile, lock, baseDir) {
482649
+ async function writeLock(lockFile, lock) {
482672
482650
  await writeFileContentRaw(
482673
482651
  lockFile,
482674
- await formatAsLocal(
482675
- JSON.stringify(lock, void 0, 2),
482676
- "/tmp/x.json",
482677
- baseDir
482678
- ),
482652
+ await formatAsLocal(JSON.stringify(lock, void 0, 2), "/tmp/x.json"),
482679
482653
  {
482680
482654
  force: true
482681
482655
  }
482682
482656
  );
482683
482657
  }
482684
- async function updateConfig(context, newConfig, baseDir) {
482685
- await writeConfig(context.configFile, newConfig, baseDir);
482658
+ async function updateConfig(context, newConfig) {
482659
+ await writeConfig(context.configFile, newConfig);
482686
482660
  context.config = newConfig;
482687
- await writeLock(context.lockFile, context.lock, baseDir);
482661
+ await writeLock(context.lockFile, context.lock);
482688
482662
  }
482689
482663
  function getOrAddProjectConfig(context, projectId, base) {
482690
482664
  let project = context.config.projects.find((p5) => p5.projectId === projectId);
@@ -483207,11 +483181,18 @@ var import_upath5 = __toESM(require_upath());
483207
483181
  // src/utils/envdetect.ts
483208
483182
  init_import_meta_url();
483209
483183
  var import_findup_sync2 = __toESM(require_findup_sync());
483184
+ var import_semver2 = __toESM(require_semver2());
483210
483185
  function detectTypescript() {
483211
483186
  return (0, import_findup_sync2.default)("tsconfig.json");
483212
483187
  }
483213
483188
  function detectNextJs() {
483214
- if ((0, import_findup_sync2.default)("next.config.js") || (0, import_findup_sync2.default)(".next") || (0, import_findup_sync2.default)("next-env.d.ts")) {
483189
+ if ((0, import_findup_sync2.default)([
483190
+ "next.config.js",
483191
+ "next.config.ts",
483192
+ "next.config.mjs",
483193
+ ".next/",
483194
+ "next-env.d.ts"
483195
+ ])) {
483215
483196
  return true;
483216
483197
  }
483217
483198
  try {
@@ -483222,12 +483203,36 @@ function detectNextJs() {
483222
483203
  }
483223
483204
  }
483224
483205
  function detectNextJsAppDir() {
483225
- var _a8, _b2;
483206
+ var _a8, _b2, _c3;
483207
+ if (!detectNextJs()) {
483208
+ return false;
483209
+ }
483226
483210
  const nextConfigPath = (0, import_findup_sync2.default)("next.config.js");
483227
- if (!nextConfigPath) {
483211
+ if (nextConfigPath && ((_b2 = (_a8 = require(nextConfigPath)) == null ? void 0 : _a8.experimental) == null ? void 0 : _b2.appDir)) {
483212
+ return true;
483213
+ }
483214
+ if (!(0, import_findup_sync2.default)("app")) {
483228
483215
  return false;
483229
483216
  }
483230
- return ((_b2 = (_a8 = require(nextConfigPath)) == null ? void 0 : _a8.experimental) == null ? void 0 : _b2.appDir) || false;
483217
+ if (!(0, import_findup_sync2.default)("pages")) {
483218
+ return true;
483219
+ }
483220
+ try {
483221
+ const packageJson = getParsedPackageJson();
483222
+ const nextVersion = (_c3 = packageJson.dependencies) == null ? void 0 : _c3.next;
483223
+ if (nextVersion) {
483224
+ if (nextVersion === "latest") {
483225
+ return true;
483226
+ }
483227
+ const coercedVersion = import_semver2.default.coerce(nextVersion);
483228
+ if (coercedVersion && import_semver2.default.gte(coercedVersion, "13.4.0")) {
483229
+ return true;
483230
+ }
483231
+ }
483232
+ } catch {
483233
+ return false;
483234
+ }
483235
+ return false;
483231
483236
  }
483232
483237
  function detectGatsby() {
483233
483238
  return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
@@ -483251,8 +483256,9 @@ function detectTanStackApp() {
483251
483256
 
483252
483257
  // src/actions/init.ts
483253
483258
  async function initPlasmic(opts) {
483254
- if (!opts.baseDir)
483259
+ if (!opts.baseDir) {
483255
483260
  opts.baseDir = process.cwd();
483261
+ }
483256
483262
  await getOrStartAuth(opts);
483257
483263
  const configFile = opts.config || findConfigFile(opts.baseDir, { traverseParents: false });
483258
483264
  if (configFile && existsBuffered(configFile)) {
@@ -483264,7 +483270,7 @@ async function initPlasmic(opts) {
483264
483270
  const newConfigFile = opts.config || import_upath5.default.join(opts.baseDir, CONFIG_FILE_NAME);
483265
483271
  const answers = await deriveInitAnswers(opts);
483266
483272
  const initConfig = createInitConfig(answers);
483267
- await writeConfig(newConfigFile, initConfig, opts.baseDir);
483273
+ await writeConfig(newConfigFile, initConfig);
483268
483274
  if (!process.env.QUIET) {
483269
483275
  logger.info("Successfully created plasmic.json.\n");
483270
483276
  }
@@ -483328,7 +483334,7 @@ function simulatePrompt(question, defaultAnswer, bold = false) {
483328
483334
  }
483329
483335
  async function deriveInitAnswers(opts) {
483330
483336
  const plasmicRootDir = opts.config ? import_upath5.default.dirname(opts.config) : opts.baseDir;
483331
- const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
483337
+ const platform = opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
483332
483338
  const isCra = platform === "react";
483333
483339
  const isNext = platform === "nextjs";
483334
483340
  const isNextAppDir = isNext && detectNextJsAppDir();
@@ -483396,7 +483402,6 @@ async function deriveInitAnswers(opts) {
483396
483402
  pagesDir: getDefaultAnswer("pagesDir", void 0),
483397
483403
  reactRuntime: getDefaultAnswer("reactRuntime", "classic")
483398
483404
  };
483399
- const prominentAnswers = import_lodash11.default.omit(answers, "codeScheme");
483400
483405
  if (process.env.QUIET) {
483401
483406
  return answers;
483402
483407
  }
@@ -483708,7 +483713,7 @@ function getInitArgsQuestion(key2) {
483708
483713
  init_import_meta_url();
483709
483714
  var import_chalk3 = __toESM(require_source());
483710
483715
  var import_lodash13 = __toESM(require_lodash());
483711
- var import_semver2 = __toESM(require_semver2());
483716
+ var import_semver3 = __toESM(require_semver2());
483712
483717
  var import_upath7 = __toESM(require_upath());
483713
483718
 
483714
483719
  // src/migrations/0.1.110-fileLocks.ts
@@ -483859,7 +483864,7 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
483859
483864
  };
483860
483865
  const cur = readConfig(configFile, false);
483861
483866
  const curVersion = cur.cliVersion;
483862
- if (!!curVersion && import_semver2.default.lt(cliVersion, curVersion)) {
483867
+ if (!!curVersion && import_semver3.default.lt(cliVersion, curVersion)) {
483863
483868
  const confirm = await confirmWithUser(
483864
483869
  `Project requires @plasmicapp/cli>=${curVersion} (You currently have ${cliVersion}). Would you like to upgrade it?`,
483865
483870
  yes
@@ -483879,9 +483884,9 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
483879
483884
  const context = {
483880
483885
  absoluteSrcDir: import_upath7.default.isAbsolute(cur.srcDir) ? cur.srcDir : import_upath7.default.resolve(import_upath7.default.dirname(configFile), cur.srcDir)
483881
483886
  };
483882
- const greaterVersions = import_semver2.default.sort(
483887
+ const greaterVersions = import_semver3.default.sort(
483883
483888
  [...import_lodash13.default.keys(MIGRATIONS), ...import_lodash13.default.keys(LOCK_MIGRATIONS)].filter(
483884
- (v7) => !curVersion || import_semver2.default.gt(v7, curVersion)
483889
+ (v7) => !curVersion || import_semver3.default.gt(v7, curVersion)
483885
483890
  )
483886
483891
  );
483887
483892
  for (const version of greaterVersions) {
@@ -483891,21 +483896,21 @@ async function runNecessaryMigrations(configFile, lockFile, baseDir, yes) {
483891
483896
  const prev2 = readConfig(configFile, false);
483892
483897
  const next = migrationFunc(prev2, context);
483893
483898
  next.cliVersion = version;
483894
- await writeConfig(configFile, next, baseDir);
483899
+ await writeConfig(configFile, next);
483895
483900
  }
483896
483901
  const lockMigrationFunc = LOCK_MIGRATIONS[version];
483897
483902
  if (lockMigrationFunc !== void 0) {
483898
483903
  const prev2 = maybeReadLock();
483899
483904
  if (prev2) {
483900
483905
  const next = lockMigrationFunc(prev2, context);
483901
- await writeLock(lockFile, next, baseDir);
483906
+ await writeLock(lockFile, next);
483902
483907
  }
483903
483908
  }
483904
483909
  }
483905
483910
  const latestConfig = readConfig(configFile, false);
483906
483911
  if (latestConfig.cliVersion !== cliVersion) {
483907
483912
  latestConfig.cliVersion = cliVersion;
483908
- await writeConfig(configFile, latestConfig, baseDir);
483913
+ await writeConfig(configFile, latestConfig);
483909
483914
  }
483910
483915
  }
483911
483916
 
@@ -484317,7 +484322,7 @@ async function exportProjectsCli(opts) {
484317
484322
  const outPath = import_path12.default.resolve(opts.outDir);
484318
484323
  const writeFile = async (fileName, content) => {
484319
484324
  if (typeof content === "string" && !opts.skipFormatting) {
484320
- content = await formatAsLocal(content, fileName, opts.outDir);
484325
+ content = await formatAsLocal(content, fileName);
484321
484326
  }
484322
484327
  const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
484323
484328
  await import_fs5.promises.mkdir(import_path12.default.join(outPath, projectName), { recursive: true });
@@ -484371,109 +484376,106 @@ async function exportProjectsCli(opts) {
484371
484376
  }
484372
484377
  };
484373
484378
  await Promise.all(result.map((res) => writeProj(res)));
484374
- await fixAllImportStatements(
484375
- {
484376
- configFile: "",
484377
- lockFile: "",
484378
- rootDir: import_path12.default.resolve(opts.outDir),
484379
- absoluteSrcDir: import_path12.default.resolve(opts.outDir),
484380
- config: {
484381
- platform: opts.platform || "react",
484382
- srcDir: "./",
484383
- defaultPlasmicDir: "./",
484384
- preserveJsImportExtensions: false,
484385
- code: {
484386
- lang: opts.codeLang || "ts",
484387
- scheme: "blackbox",
484388
- reactRuntime: "classic"
484389
- },
484390
- images: {
484391
- scheme: opts.imagesScheme || "files"
484392
- },
484393
- style: {
484394
- scheme: opts.styleScheme || "css-modules",
484395
- defaultStyleCssFilePath: ""
484396
- },
484397
- tokens: {},
484398
- globalVariants: {
484399
- variantGroups: result.flatMap((bundle) => {
484400
- const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
484401
- return bundle.globalVariants.map((gv) => ({
484402
- id: gv.id,
484403
- name: gv.name,
484404
- projectId: bundle.projectConfig.projectId,
484405
- contextFilePath: `./${projectName}/${gv.contextFileName}`
484406
- }));
484407
- })
484408
- },
484409
- projects: result.map((bundle) => {
484410
- var _a9;
484379
+ await fixAllImportStatements({
484380
+ configFile: "",
484381
+ lockFile: "",
484382
+ rootDir: import_path12.default.resolve(opts.outDir),
484383
+ absoluteSrcDir: import_path12.default.resolve(opts.outDir),
484384
+ config: {
484385
+ platform: opts.platform || "react",
484386
+ srcDir: "./",
484387
+ defaultPlasmicDir: "./",
484388
+ preserveJsImportExtensions: false,
484389
+ code: {
484390
+ lang: opts.codeLang || "ts",
484391
+ scheme: "blackbox",
484392
+ reactRuntime: "classic"
484393
+ },
484394
+ images: {
484395
+ scheme: opts.imagesScheme || "files"
484396
+ },
484397
+ style: {
484398
+ scheme: opts.styleScheme || "css-modules",
484399
+ defaultStyleCssFilePath: ""
484400
+ },
484401
+ tokens: {},
484402
+ globalVariants: {
484403
+ variantGroups: result.flatMap((bundle) => {
484411
484404
  const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
484412
- return {
484405
+ return bundle.globalVariants.map((gv) => ({
484406
+ id: gv.id,
484407
+ name: gv.name,
484413
484408
  projectId: bundle.projectConfig.projectId,
484414
- projectName: bundle.projectConfig.projectName,
484415
- version: "latest",
484416
- cssFilePath: `${projectName}/${bundle.projectConfig.cssFileName}`,
484417
- globalContextsFilePath: bundle.projectConfig.globalContextBundle ? `${projectName}/${DEFAULT_GLOBAL_CONTEXTS_NAME}.${extx}` : "",
484418
- splitsProviderFilePath: bundle.projectConfig.splitsProviderBundle ? `${projectName}/${DEFAULT_SPLITS_PROVIDER_NAME}.${extx}` : "",
484419
- styleTokensProviderFilePath: bundle.projectConfig.styleTokensProviderBundle ? `${projectName}/${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.${extx}` : "",
484420
- dataTokensFilePath: bundle.projectConfig.dataTokensBundle ? `${projectName}/${DEFAULT_DATA_TOKENS_NAME}.${opts.codeLang}` : "",
484421
- projectModuleFilePath: bundle.projectConfig.projectModuleBundle ? `${projectName}/${DEFAULT_PROJECT_MODULE_NAME}.${extx}` : "",
484422
- components: bundle.components.map((comp) => ({
484423
- id: comp.id,
484424
- name: comp.componentName,
484425
- projectId: bundle.projectConfig.projectId,
484426
- type: "managed",
484427
- importSpec: {
484428
- modulePath: `${projectName}/${comp.skeletonModuleFileName}`
484429
- },
484430
- renderModuleFilePath: `${projectName}/${comp.skeletonModuleFileName}`,
484431
- cssFilePath: `${projectName}/${comp.cssFileName}`,
484432
- scheme: "blackbox",
484433
- componentType: `${comp.isPage ? "page" : "component"}`,
484434
- plumeType: comp.plumeType
484435
- })),
484436
- codeComponents: bundle.codeComponentMetas.map((comp) => ({
484437
- id: comp.id,
484438
- name: comp.name,
484439
- displayName: comp.displayName,
484440
- componentImportPath: comp.importPath,
484441
- helper: comp.helper
484442
- })),
484443
- customFunctionMetas: ((_a9 = bundle.customFunctionMetas) != null ? _a9 : []).map(
484444
- (meta) => {
484445
- var _a10;
484446
- return {
484447
- id: meta.id,
484448
- name: meta.name,
484449
- importPath: meta.importPath,
484450
- defaultExport: meta.defaultExport,
484451
- namespace: (_a10 = meta.namespace) != null ? _a10 : null
484452
- };
484453
- }
484454
- ),
484455
- icons: bundle.iconAssets.map((icon) => ({
484456
- id: icon.id,
484457
- name: icon.name,
484458
- moduleFilePath: `${projectName}/${icon.fileName}`
484459
- })),
484460
- images: bundle.imageAssets.map((image) => ({
484461
- id: image.id,
484462
- name: image.name,
484463
- filePath: `${projectName}/${image.fileName}`
484464
- })),
484465
- indirect: false
484466
- };
484467
- }),
484468
- wrapPagesWithGlobalContexts: true
484409
+ contextFilePath: `./${projectName}/${gv.contextFileName}`
484410
+ }));
484411
+ })
484469
484412
  },
484470
- lock: {},
484471
- auth: {},
484472
- api,
484473
- cliArgs: {}
484413
+ projects: result.map((bundle) => {
484414
+ var _a9;
484415
+ const projectName = (0, import_lodash15.snakeCase)(bundle.projectConfig.projectName);
484416
+ return {
484417
+ projectId: bundle.projectConfig.projectId,
484418
+ projectName: bundle.projectConfig.projectName,
484419
+ version: "latest",
484420
+ cssFilePath: `${projectName}/${bundle.projectConfig.cssFileName}`,
484421
+ globalContextsFilePath: bundle.projectConfig.globalContextBundle ? `${projectName}/${DEFAULT_GLOBAL_CONTEXTS_NAME}.${extx}` : "",
484422
+ splitsProviderFilePath: bundle.projectConfig.splitsProviderBundle ? `${projectName}/${DEFAULT_SPLITS_PROVIDER_NAME}.${extx}` : "",
484423
+ styleTokensProviderFilePath: bundle.projectConfig.styleTokensProviderBundle ? `${projectName}/${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.${extx}` : "",
484424
+ dataTokensFilePath: bundle.projectConfig.dataTokensBundle ? `${projectName}/${DEFAULT_DATA_TOKENS_NAME}.${opts.codeLang}` : "",
484425
+ projectModuleFilePath: bundle.projectConfig.projectModuleBundle ? `${projectName}/${DEFAULT_PROJECT_MODULE_NAME}.${extx}` : "",
484426
+ components: bundle.components.map((comp) => ({
484427
+ id: comp.id,
484428
+ name: comp.componentName,
484429
+ projectId: bundle.projectConfig.projectId,
484430
+ type: "managed",
484431
+ importSpec: {
484432
+ modulePath: `${projectName}/${comp.skeletonModuleFileName}`
484433
+ },
484434
+ renderModuleFilePath: `${projectName}/${comp.skeletonModuleFileName}`,
484435
+ cssFilePath: `${projectName}/${comp.cssFileName}`,
484436
+ scheme: "blackbox",
484437
+ componentType: `${comp.isPage ? "page" : "component"}`,
484438
+ plumeType: comp.plumeType
484439
+ })),
484440
+ codeComponents: bundle.codeComponentMetas.map((comp) => ({
484441
+ id: comp.id,
484442
+ name: comp.name,
484443
+ displayName: comp.displayName,
484444
+ componentImportPath: comp.importPath,
484445
+ helper: comp.helper
484446
+ })),
484447
+ customFunctionMetas: ((_a9 = bundle.customFunctionMetas) != null ? _a9 : []).map(
484448
+ (meta) => {
484449
+ var _a10;
484450
+ return {
484451
+ id: meta.id,
484452
+ name: meta.name,
484453
+ importPath: meta.importPath,
484454
+ defaultExport: meta.defaultExport,
484455
+ namespace: (_a10 = meta.namespace) != null ? _a10 : null
484456
+ };
484457
+ }
484458
+ ),
484459
+ icons: bundle.iconAssets.map((icon) => ({
484460
+ id: icon.id,
484461
+ name: icon.name,
484462
+ moduleFilePath: `${projectName}/${icon.fileName}`
484463
+ })),
484464
+ images: bundle.imageAssets.map((image) => ({
484465
+ id: image.id,
484466
+ name: image.name,
484467
+ filePath: `${projectName}/${image.fileName}`
484468
+ })),
484469
+ indirect: false
484470
+ };
484471
+ }),
484472
+ wrapPagesWithGlobalContexts: true
484474
484473
  },
484475
- opts.outDir
484476
- );
484474
+ lock: {},
484475
+ auth: {},
484476
+ api,
484477
+ cliArgs: {}
484478
+ });
484477
484479
  }
484478
484480
  async function exportProjects(api, opts) {
484479
484481
  var _a8;
@@ -484528,53 +484530,46 @@ async function exportProjects(api, opts) {
484528
484530
  for (const comp of proj.components) {
484529
484531
  [comp.skeletonModuleFileName, comp.skeletonModule] = await maybeConvertTsxToJsx(
484530
484532
  comp.skeletonModuleFileName,
484531
- comp.skeletonModule,
484532
- "."
484533
+ comp.skeletonModule
484533
484534
  );
484534
484535
  }
484535
484536
  for (const icon of proj.iconAssets) {
484536
484537
  [icon.fileName, icon.module] = await maybeConvertTsxToJsx(
484537
484538
  icon.fileName,
484538
- icon.module,
484539
- "."
484539
+ icon.module
484540
484540
  );
484541
484541
  }
484542
484542
  for (const gv of proj.globalVariants) {
484543
484543
  [gv.contextFileName, gv.contextModule] = await maybeConvertTsxToJsx(
484544
484544
  gv.contextFileName,
484545
- gv.contextModule,
484546
- "."
484545
+ gv.contextModule
484547
484546
  );
484548
484547
  }
484549
484548
  if (proj.projectConfig.globalContextBundle) {
484550
484549
  const res = await maybeConvertTsxToJsx(
484551
484550
  `${DEFAULT_GLOBAL_CONTEXTS_NAME}.tsx`,
484552
- proj.projectConfig.globalContextBundle.contextModule,
484553
- "."
484551
+ proj.projectConfig.globalContextBundle.contextModule
484554
484552
  );
484555
484553
  proj.projectConfig.globalContextBundle.contextModule = res[1];
484556
484554
  }
484557
484555
  if (proj.projectConfig.splitsProviderBundle) {
484558
484556
  const res = await maybeConvertTsxToJsx(
484559
484557
  `${DEFAULT_SPLITS_PROVIDER_NAME}.tsx`,
484560
- proj.projectConfig.splitsProviderBundle.module,
484561
- "."
484558
+ proj.projectConfig.splitsProviderBundle.module
484562
484559
  );
484563
484560
  proj.projectConfig.splitsProviderBundle.module = res[1];
484564
484561
  }
484565
484562
  if (proj.projectConfig.styleTokensProviderBundle) {
484566
484563
  const res = await maybeConvertTsxToJsx(
484567
484564
  `${DEFAULT_STYLE_TOKENS_PROVIDER_NAME}.tsx`,
484568
- proj.projectConfig.styleTokensProviderBundle.module,
484569
- "."
484565
+ proj.projectConfig.styleTokensProviderBundle.module
484570
484566
  );
484571
484567
  proj.projectConfig.styleTokensProviderBundle.module = res[1];
484572
484568
  }
484573
484569
  if (proj.projectConfig.projectModuleBundle) {
484574
484570
  const res = await maybeConvertTsxToJsx(
484575
484571
  `${DEFAULT_PROJECT_MODULE_NAME}.tsx`,
484576
- proj.projectConfig.projectModuleBundle.module,
484577
- "."
484572
+ proj.projectConfig.projectModuleBundle.module
484578
484573
  );
484579
484574
  proj.projectConfig.projectModuleBundle.module = res[1];
484580
484575
  }
@@ -484586,14 +484581,15 @@ async function exportProjects(api, opts) {
484586
484581
  // src/actions/fix-imports.ts
484587
484582
  init_import_meta_url();
484588
484583
  async function fixImports(opts) {
484589
- if (!opts.baseDir)
484584
+ if (!opts.baseDir) {
484590
484585
  opts.baseDir = process.cwd();
484586
+ }
484591
484587
  if (opts.skipFormatting) {
484592
484588
  GLOBAL_SETTINGS.skipFormatting = true;
484593
484589
  }
484594
484590
  const context = await getContext(opts, { enableSkipAuth: true });
484595
- await updateConfig(context, context.config, opts.baseDir);
484596
- await fixAllImportStatements(context, opts.baseDir);
484591
+ await updateConfig(context, context.config);
484592
+ await fixAllImportStatements(context);
484597
484593
  }
484598
484594
 
484599
484595
  // src/actions/localization-strings.ts
@@ -485175,30 +485171,43 @@ async function syncRscFiles(context, project, bundle, compConfig, opts) {
485175
485171
  clientModulePath: ""
485176
485172
  };
485177
485173
  }
485178
- const serverModuleFilePath = defaultResourcePath(
485174
+ let serverModuleFilePath = defaultResourcePath(
485179
485175
  context,
485180
485176
  project,
485181
485177
  rscMetadata.pageWrappers.server.fileName
485182
485178
  );
485179
+ let serverModuleContent = rscMetadata.pageWrappers.server.module;
485180
+ if (context.config.code.lang === "js") {
485181
+ const [convertedFileName, convertedContent] = await maybeConvertTsxToJsx(
485182
+ serverModuleFilePath,
485183
+ serverModuleContent
485184
+ );
485185
+ serverModuleFilePath = convertedFileName;
485186
+ serverModuleContent = convertedContent;
485187
+ }
485183
485188
  compConfig.rsc.serverModulePath = serverModuleFilePath;
485184
- await writeFileContent(
485185
- context,
485186
- serverModuleFilePath,
485187
- rscMetadata.pageWrappers.server.module,
485188
- {
485189
- force: true
485190
- }
485191
- );
485192
- const clientModuleFilePath = compConfig.importSpec.modulePath.replace(
485193
- /\.tsx$/,
485189
+ await writeFileContent(context, serverModuleFilePath, serverModuleContent, {
485190
+ force: true
485191
+ });
485192
+ let clientModuleFilePath = compConfig.importSpec.modulePath.replace(
485193
+ /\.(tsx|jsx)$/,
485194
485194
  "-client.tsx"
485195
485195
  );
485196
+ let clientModuleContent = rscMetadata.pageWrappers.client.module;
485197
+ if (context.config.code.lang === "js") {
485198
+ const [convertedFileName, convertedContent] = await maybeConvertTsxToJsx(
485199
+ clientModuleFilePath,
485200
+ clientModuleContent
485201
+ );
485202
+ clientModuleFilePath = convertedFileName;
485203
+ clientModuleContent = convertedContent;
485204
+ }
485196
485205
  compConfig.rsc.clientModulePath = clientModuleFilePath;
485197
485206
  if (opts.shouldRegenerate) {
485198
485207
  await writeFileContent(
485199
485208
  context,
485200
485209
  clientModuleFilePath,
485201
- rscMetadata.pageWrappers.client.module,
485210
+ clientModuleContent,
485202
485211
  {
485203
485212
  force: false
485204
485213
  }
@@ -485208,7 +485217,7 @@ async function syncRscFiles(context, project, bundle, compConfig, opts) {
485208
485217
  }
485209
485218
 
485210
485219
  // src/actions/sync-components.ts
485211
- async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums, baseDir) {
485220
+ async function syncProjectComponents(context, project, version, componentBundles, forceOverwrite, summary, projectLock, checksums) {
485212
485221
  var _a8;
485213
485222
  const componentsFromChecksums = /* @__PURE__ */ new Set([
485214
485223
  ...checksums.cssRulesChecksums.map(([id2, _7]) => id2),
@@ -485272,7 +485281,6 @@ async function syncProjectComponents(context, project, version, componentBundles
485272
485281
  componentName,
485273
485282
  id: id2,
485274
485283
  scheme,
485275
- nameInIdToUuid,
485276
485284
  isPage,
485277
485285
  path: pagePath,
485278
485286
  plumeType
@@ -485318,7 +485326,6 @@ async function syncProjectComponents(context, project, version, componentBundles
485318
485326
  await writeFileContent(context, skeletonPath, skeletonModule, {
485319
485327
  force: false
485320
485328
  });
485321
- } else if (compConfig.type === "mapped") {
485322
485329
  } else if (compConfig.type === "managed") {
485323
485330
  compConfig.componentType = isPage ? "page" : "component";
485324
485331
  let editedFile;
@@ -485439,8 +485446,7 @@ async function syncProjectComponents(context, project, version, componentBundles
485439
485446
  );
485440
485447
  const formattedCssRules = await formatAsLocal(
485441
485448
  cssRules,
485442
- compConfig.cssFilePath,
485443
- baseDir
485449
+ compConfig.cssFilePath
485444
485450
  );
485445
485451
  await writeFileContent(
485446
485452
  context,
@@ -485462,7 +485468,7 @@ async function syncProjectComponents(context, project, version, componentBundles
485462
485468
  init_import_meta_url();
485463
485469
  var import_lodash21 = __toESM(require_lodash());
485464
485470
  var import_upath10 = __toESM(require_upath());
485465
- async function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName, baseDir) {
485471
+ async function syncGlobalVariants(context, projectMeta, bundles, checksums, branchName) {
485466
485472
  const projectId = projectMeta.projectId;
485467
485473
  const projectLock = getOrAddProjectLock(context, projectId, branchName);
485468
485474
  const existingVariantConfigs = import_lodash21.default.keyBy(
@@ -485535,11 +485541,7 @@ async function syncGlobalVariants(context, projectMeta, bundles, checksums, bran
485535
485541
  await writeFileContent(
485536
485542
  context,
485537
485543
  variantConfig.contextFilePath,
485538
- await formatAsLocal(
485539
- bundle.contextModule,
485540
- variantConfig.contextFilePath,
485541
- baseDir
485542
- ),
485544
+ await formatAsLocal(bundle.contextModule, variantConfig.contextFilePath),
485543
485545
  { force: !isNew }
485544
485546
  );
485545
485547
  }
@@ -485567,7 +485569,7 @@ async function syncGlobalVariants(context, projectMeta, bundles, checksums, bran
485567
485569
  init_import_meta_url();
485568
485570
  var import_lodash22 = __toESM(require_lodash());
485569
485571
  var import_upath11 = __toESM(require_upath());
485570
- async function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums, baseDir) {
485572
+ async function syncProjectIconAssets(context, projectId, branchName, version, iconBundles, checksums) {
485571
485573
  const project = getOrAddProjectConfig(context, projectId);
485572
485574
  if (!project.icons) {
485573
485575
  project.icons = [];
@@ -485636,7 +485638,7 @@ async function syncProjectIconAssets(context, projectId, branchName, version, ic
485636
485638
  await writeFileContent(
485637
485639
  context,
485638
485640
  iconConfig.moduleFilePath,
485639
- await formatAsLocal(bundle.module, iconConfig.moduleFilePath, baseDir),
485641
+ await formatAsLocal(bundle.module, iconConfig.moduleFilePath),
485640
485642
  {
485641
485643
  force: !isNew
485642
485644
  }
@@ -485926,7 +485928,7 @@ async function sync(opts, metadataDefaults) {
485926
485928
  }
485927
485929
  });
485928
485930
  }
485929
- await fixAllImportStatements(context, opts.baseDir, summary);
485931
+ await fixAllImportStatements(context, summary);
485930
485932
  const codegenVersion = await context.api.latestCodegenVersion();
485931
485933
  context.lock.projects.forEach((p5) => {
485932
485934
  if (projectsToSync.some(
@@ -485935,7 +485937,7 @@ async function sync(opts, metadataDefaults) {
485935
485937
  p5.codegenVersion = codegenVersion;
485936
485938
  }
485937
485939
  });
485938
- await updateConfig(context, context.config, baseDir);
485940
+ await updateConfig(context, context.config);
485939
485941
  };
485940
485942
  if (opts.skipBuffering) {
485941
485943
  await doSync();
@@ -486085,27 +486087,23 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
486085
486087
  for (const c5 of projectBundle.components) {
486086
486088
  [c5.renderModuleFileName, c5.renderModule] = await maybeConvertTsxToJsx(
486087
486089
  c5.renderModuleFileName,
486088
- c5.renderModule,
486089
- opts.baseDir
486090
+ c5.renderModule
486090
486091
  );
486091
486092
  [c5.skeletonModuleFileName, c5.skeletonModule] = await maybeConvertTsxToJsx(
486092
486093
  c5.skeletonModuleFileName,
486093
- c5.skeletonModule,
486094
- opts.baseDir
486094
+ c5.skeletonModule
486095
486095
  );
486096
486096
  }
486097
486097
  for (const icon of projectBundle.iconAssets) {
486098
486098
  [icon.fileName, icon.module] = await maybeConvertTsxToJsx(
486099
486099
  icon.fileName,
486100
- icon.module,
486101
- opts.baseDir
486100
+ icon.module
486102
486101
  );
486103
486102
  }
486104
486103
  for (const gv of projectBundle.globalVariants) {
486105
486104
  [gv.contextFileName, gv.contextModule] = await maybeConvertTsxToJsx(
486106
486105
  gv.contextFileName,
486107
- gv.contextModule,
486108
- opts.baseDir
486106
+ gv.contextModule
486109
486107
  );
486110
486108
  }
486111
486109
  }
@@ -486114,8 +486112,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
486114
486112
  projectBundle.projectConfig,
486115
486113
  projectBundle.globalVariants,
486116
486114
  projectBundle.checksums,
486117
- branchName,
486118
- opts.baseDir
486115
+ branchName
486119
486116
  );
486120
486117
  await syncProjectConfig(
486121
486118
  context,
@@ -486128,7 +486125,6 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
486128
486125
  opts.forceOverwrite,
486129
486126
  summary,
486130
486127
  projectBundle.checksums,
486131
- opts.baseDir,
486132
486128
  indirect
486133
486129
  );
486134
486130
  syncCodeComponentsMeta(context, projectId, projectBundle.codeComponentMetas);
@@ -486148,8 +486144,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
486148
486144
  branchName,
486149
486145
  projectVersion,
486150
486146
  projectBundle.iconAssets,
486151
- projectBundle.checksums,
486152
- opts.baseDir
486147
+ projectBundle.checksums
486153
486148
  );
486154
486149
  await syncProjectImageAssets(
486155
486150
  context,
@@ -486176,7 +486171,7 @@ async function syncStyleConfig(context, response) {
486176
486171
  force: true
486177
486172
  });
486178
486173
  }
486179
- async function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, summary, checksums, baseDir, indirect) {
486174
+ async function syncProjectConfig(context, projectBundle, projectApiToken, branchName, version, dependencies, componentBundles, forceOverwrite, summary, checksums, indirect) {
486180
486175
  const defaultCssFilePath = defaultResourcePath(
486181
486176
  context,
486182
486177
  projectBundle.projectName,
@@ -486212,8 +486207,7 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
486212
486207
  if (projectBundle.cssRules) {
486213
486208
  const formattedCssRules = await formatAsLocal(
486214
486209
  projectBundle.cssRules,
486215
- projectConfig.cssFilePath,
486216
- baseDir
486210
+ projectConfig.cssFilePath
486217
486211
  );
486218
486212
  await writeFileContent(
486219
486213
  context,
@@ -486237,40 +486231,35 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
486237
486231
  projectBundle,
486238
486232
  projectConfig,
486239
486233
  projectLock,
486240
- checksums,
486241
- baseDir
486234
+ checksums
486242
486235
  );
486243
486236
  await syncSplitsProvider(
486244
486237
  context,
486245
486238
  projectBundle,
486246
486239
  projectConfig,
486247
486240
  projectLock,
486248
- checksums,
486249
- baseDir
486241
+ checksums
486250
486242
  );
486251
486243
  await syncProjectModule(
486252
486244
  context,
486253
486245
  projectBundle,
486254
486246
  projectConfig,
486255
486247
  projectLock,
486256
- checksums,
486257
- baseDir
486248
+ checksums
486258
486249
  );
486259
486250
  await syncStyleTokensProvider(
486260
486251
  context,
486261
486252
  projectBundle,
486262
486253
  projectConfig,
486263
486254
  projectLock,
486264
- checksums,
486265
- baseDir
486255
+ checksums
486266
486256
  );
486267
486257
  await syncDataTokens(
486268
486258
  context,
486269
486259
  projectBundle,
486270
486260
  projectConfig,
486271
486261
  projectLock,
486272
- checksums,
486273
- baseDir
486262
+ checksums
486274
486263
  );
486275
486264
  await syncProjectComponents(
486276
486265
  context,
@@ -486280,8 +486269,7 @@ async function syncProjectConfig(context, projectBundle, projectApiToken, branch
486280
486269
  forceOverwrite,
486281
486270
  summary,
486282
486271
  projectLock,
486283
- checksums,
486284
- baseDir
486272
+ checksums
486285
486273
  );
486286
486274
  }
486287
486275
  function syncCodeComponentsMeta(context, projectId, codeComponentBundles) {