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