@plasmicapp/cli 0.1.297 → 0.1.299

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.
@@ -1,4 +1,5 @@
1
1
  import { CommonArgs } from "..";
2
2
  export interface FixImportsArgs extends CommonArgs {
3
+ skipFormatting?: boolean;
3
4
  }
4
5
  export declare function fixImports(opts: FixImportsArgs): Promise<void>;
@@ -12,6 +12,7 @@ export interface SyncArgs extends CommonArgs {
12
12
  metadata?: string;
13
13
  allFiles?: boolean;
14
14
  loaderConfig?: string;
15
+ skipFormatting?: boolean;
15
16
  }
16
17
  /**
17
18
  * Sync will always try to sync down a set of components that are version-consistent among specified projects.
@@ -0,0 +1,3 @@
1
+ export declare const GLOBAL_SETTINGS: {
2
+ skipFormatting: boolean;
3
+ };
package/dist/index.js CHANGED
@@ -735124,8 +735124,16 @@ async function fixComponentImagesReferences(context, fixImportContext, renderMod
735124
735124
  return false;
735125
735125
  }
735126
735126
 
735127
+ // src/globals.ts
735128
+ var GLOBAL_SETTINGS = {
735129
+ skipFormatting: false
735130
+ };
735131
+
735127
735132
  // src/utils/code-utils.ts
735128
735133
  var formatAsLocal = (content, filePath, baseDir, defaultOpts = {}) => {
735134
+ if (GLOBAL_SETTINGS.skipFormatting) {
735135
+ return content;
735136
+ }
735129
735137
  const opts = { ...defaultOpts };
735130
735138
  opts.filepath = filePath;
735131
735139
  const res = Prettier.format(content, opts);
@@ -737809,6 +737817,9 @@ function generateMetadata(defaults, fromArgs) {
737809
737817
  async function fixImports(opts) {
737810
737818
  if (!opts.baseDir)
737811
737819
  opts.baseDir = process.cwd();
737820
+ if (opts.skipFormatting) {
737821
+ GLOBAL_SETTINGS.skipFormatting = true;
737822
+ }
737812
737823
  const context = await getContext(opts, { enableSkipAuth: true });
737813
737824
  await updateConfig(context, context.config, opts.baseDir);
737814
737825
  await fixAllImportStatements(context, opts.baseDir);
@@ -737867,6 +737878,29 @@ var import_lodash17 = __toESM(require_lodash());
737867
737878
  var import_upath12 = __toESM(require_upath());
737868
737879
 
737869
737880
  // src/utils/checksum.ts
737881
+ function getFilesByFileLockAssetId(context, projectConfig) {
737882
+ return {
737883
+ renderModule: Object.fromEntries(
737884
+ projectConfig.components.map((c) => [c.id, c.renderModuleFilePath])
737885
+ ),
737886
+ cssRules: Object.fromEntries(
737887
+ projectConfig.components.map((c) => [c.id, c.cssFilePath])
737888
+ ),
737889
+ icon: Object.fromEntries(
737890
+ projectConfig.icons.map((i) => [i.id, i.moduleFilePath])
737891
+ ),
737892
+ image: Object.fromEntries(
737893
+ projectConfig.images.map((i) => [i.id, i.filePath])
737894
+ ),
737895
+ projectCss: { [projectConfig.projectId]: projectConfig.cssFilePath },
737896
+ globalVariant: Object.fromEntries(
737897
+ context.config.globalVariants.variantGroups.filter((vg) => vg.projectId === projectConfig.projectId).map((vg) => [vg.id, vg.contextFilePath])
737898
+ ),
737899
+ globalContext: {
737900
+ [projectConfig.projectId]: projectConfig.globalContextsFilePath
737901
+ }
737902
+ };
737903
+ }
737870
737904
  function getChecksums(context, opts, projectId, componentIds) {
737871
737905
  const projectConfig = context.config.projects.find(
737872
737906
  (p) => p.projectId === projectId
@@ -737885,6 +737919,13 @@ function getChecksums(context, opts, projectId, componentIds) {
737885
737919
  globalContextsChecksum: ""
737886
737920
  };
737887
737921
  }
737922
+ const fileLocations = getFilesByFileLockAssetId(context, projectConfig);
737923
+ const checkFile = (file) => {
737924
+ if (!file) {
737925
+ return false;
737926
+ }
737927
+ return fileExists(context, file);
737928
+ };
737888
737929
  const fileLocks = projectLock.fileLocks;
737889
737930
  const knownImages = new Set(projectConfig.images.map((i) => i.id));
737890
737931
  const knownIcons = new Set(projectConfig.icons.map((i) => i.id));
@@ -737892,32 +737933,35 @@ function getChecksums(context, opts, projectId, componentIds) {
737892
737933
  const knownGlobalVariants = new Set(
737893
737934
  context.config.globalVariants.variantGroups.filter((vg) => vg.projectId === projectId).map((vg) => vg.id)
737894
737935
  );
737895
- const knownThemes = new Set(
737896
- (projectConfig.jsBundleThemes || []).map((theme) => theme.bundleName)
737897
- );
737898
737936
  const toBeSyncedComponents = new Set(componentIds);
737899
737937
  const imageChecksums = fileLocks.filter(
737900
737938
  (fileLock) => fileLock.type === "image" && knownImages.has(fileLock.assetId)
737901
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737939
+ ).filter((fileLock) => checkFile(fileLocations.image[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737902
737940
  const iconChecksums = fileLocks.filter(
737903
737941
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "icon" && knownIcons.has(fileLock.assetId)
737904
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737942
+ ).filter((fileLock) => checkFile(fileLocations.icon[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737905
737943
  const renderModuleChecksums = fileLocks.filter(
737906
737944
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "renderModule" && toBeSyncedComponents.has(fileLock.assetId) && knownComponents.has(fileLock.assetId)
737945
+ ).filter(
737946
+ (fileLock) => checkFile(fileLocations.renderModule[fileLock.assetId])
737907
737947
  ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737908
737948
  const cssRulesChecksums = fileLocks.filter(
737909
737949
  (fileLock) => fileLock.type === "cssRules" && toBeSyncedComponents.has(fileLock.assetId) && knownComponents.has(fileLock.assetId)
737910
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737950
+ ).filter((fileLock) => checkFile(fileLocations.cssRules[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737911
737951
  const globalVariantChecksums = fileLocks.filter(
737912
737952
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "globalVariant" && knownGlobalVariants.has(fileLock.assetId)
737953
+ ).filter(
737954
+ (fileLock) => checkFile(fileLocations.globalVariant[fileLock.assetId])
737913
737955
  ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
737914
- const projectCssChecksums = fileLocks.filter(
737915
- (fileLock) => fileLock.type === "projectCss"
737956
+ const projectCssChecksums = fileLocks.filter((fileLock) => fileLock.type === "projectCss").filter(
737957
+ (fileLock) => checkFile(fileLocations.projectCss[fileLock.assetId])
737916
737958
  );
737917
737959
  assert(projectCssChecksums.length < 2);
737918
737960
  const projectCssChecksum = projectCssChecksums.length > 0 ? projectCssChecksums[0].checksum : "";
737919
737961
  const globalContextsChecksums = fileLocks.filter(
737920
737962
  (fileLock) => fileLock.type === "globalContexts" && fileLock.assetId === projectId
737963
+ ).filter(
737964
+ (fileLock) => checkFile(fileLocations.globalContext[fileLock.assetId])
737921
737965
  );
737922
737966
  assert(globalContextsChecksums.length < 2);
737923
737967
  const globalContextsChecksum = globalContextsChecksums.length > 0 ? globalContextsChecksums[0].checksum : "";
@@ -738799,6 +738843,9 @@ async function sync(opts, metadataDefaults) {
738799
738843
  opts.baseDir = process.cwd();
738800
738844
  const baseDir = opts.baseDir;
738801
738845
  let context = await getContext(opts, { enableSkipAuth: true });
738846
+ if (opts.skipFormatting) {
738847
+ GLOBAL_SETTINGS.skipFormatting = true;
738848
+ }
738802
738849
  const isFirstRun = context.config.projects.length === 0;
738803
738850
  if (!opts.skipUpgradeCheck) {
738804
738851
  await ensureRequiredPackages(context, opts.baseDir, opts.yes);
@@ -739555,7 +739602,11 @@ import_yargs.default.usage("Usage: $0 <command> [options]").option("auth", {
739555
739602
  ).command(
739556
739603
  "fix-imports",
739557
739604
  "Fixes import paths after you've moved around Plasmic blackbox files",
739558
- (yags) => 0,
739605
+ (yags) => yags.option("skip-formatting", {
739606
+ type: "boolean",
739607
+ describe: "Skip formatting of modified code",
739608
+ default: false
739609
+ }),
739559
739610
  (argv) => handleError(fixImports(argv))
739560
739611
  ).command(
739561
739612
  "info",
@@ -739701,6 +739752,10 @@ function configureSyncArgs(yags, includeQuietOption = true) {
739701
739752
  describe: "Pass metadata through to the server. Use querystring format (e.g. command=sync&source=cli&cli_version=1.0.0",
739702
739753
  default: "source=cli",
739703
739754
  hidden: true
739755
+ }).option("skip-formatting", {
739756
+ type: "boolean",
739757
+ describe: "Disables formatting on generated code",
739758
+ default: false
739704
739759
  }).option("all-files", {
739705
739760
  type: "boolean",
739706
739761
  describe: "Sync all files, including those that haven't changed since last sync",
package/dist/lib.js CHANGED
@@ -730464,8 +730464,16 @@ async function fixComponentImagesReferences(context, fixImportContext, renderMod
730464
730464
  return false;
730465
730465
  }
730466
730466
 
730467
+ // src/globals.ts
730468
+ var GLOBAL_SETTINGS = {
730469
+ skipFormatting: false
730470
+ };
730471
+
730467
730472
  // src/utils/code-utils.ts
730468
730473
  var formatAsLocal = (content, filePath, baseDir, defaultOpts = {}) => {
730474
+ if (GLOBAL_SETTINGS.skipFormatting) {
730475
+ return content;
730476
+ }
730469
730477
  const opts = { ...defaultOpts };
730470
730478
  opts.filepath = filePath;
730471
730479
  const res = Prettier.format(content, opts);
@@ -733139,6 +733147,9 @@ function setMetadataEnv(metadata) {
733139
733147
  async function fixImports(opts) {
733140
733148
  if (!opts.baseDir)
733141
733149
  opts.baseDir = process.cwd();
733150
+ if (opts.skipFormatting) {
733151
+ GLOBAL_SETTINGS.skipFormatting = true;
733152
+ }
733142
733153
  const context = await getContext(opts, { enableSkipAuth: true });
733143
733154
  await updateConfig(context, context.config, opts.baseDir);
733144
733155
  await fixAllImportStatements(context, opts.baseDir);
@@ -733169,6 +733180,29 @@ var import_lodash17 = __toESM(require_lodash());
733169
733180
  var import_upath12 = __toESM(require_upath());
733170
733181
 
733171
733182
  // src/utils/checksum.ts
733183
+ function getFilesByFileLockAssetId(context, projectConfig) {
733184
+ return {
733185
+ renderModule: Object.fromEntries(
733186
+ projectConfig.components.map((c) => [c.id, c.renderModuleFilePath])
733187
+ ),
733188
+ cssRules: Object.fromEntries(
733189
+ projectConfig.components.map((c) => [c.id, c.cssFilePath])
733190
+ ),
733191
+ icon: Object.fromEntries(
733192
+ projectConfig.icons.map((i) => [i.id, i.moduleFilePath])
733193
+ ),
733194
+ image: Object.fromEntries(
733195
+ projectConfig.images.map((i) => [i.id, i.filePath])
733196
+ ),
733197
+ projectCss: { [projectConfig.projectId]: projectConfig.cssFilePath },
733198
+ globalVariant: Object.fromEntries(
733199
+ context.config.globalVariants.variantGroups.filter((vg) => vg.projectId === projectConfig.projectId).map((vg) => [vg.id, vg.contextFilePath])
733200
+ ),
733201
+ globalContext: {
733202
+ [projectConfig.projectId]: projectConfig.globalContextsFilePath
733203
+ }
733204
+ };
733205
+ }
733172
733206
  function getChecksums(context, opts, projectId, componentIds) {
733173
733207
  const projectConfig = context.config.projects.find(
733174
733208
  (p) => p.projectId === projectId
@@ -733187,6 +733221,13 @@ function getChecksums(context, opts, projectId, componentIds) {
733187
733221
  globalContextsChecksum: ""
733188
733222
  };
733189
733223
  }
733224
+ const fileLocations = getFilesByFileLockAssetId(context, projectConfig);
733225
+ const checkFile = (file) => {
733226
+ if (!file) {
733227
+ return false;
733228
+ }
733229
+ return fileExists(context, file);
733230
+ };
733190
733231
  const fileLocks = projectLock.fileLocks;
733191
733232
  const knownImages = new Set(projectConfig.images.map((i) => i.id));
733192
733233
  const knownIcons = new Set(projectConfig.icons.map((i) => i.id));
@@ -733194,32 +733235,35 @@ function getChecksums(context, opts, projectId, componentIds) {
733194
733235
  const knownGlobalVariants = new Set(
733195
733236
  context.config.globalVariants.variantGroups.filter((vg) => vg.projectId === projectId).map((vg) => vg.id)
733196
733237
  );
733197
- const knownThemes = new Set(
733198
- (projectConfig.jsBundleThemes || []).map((theme) => theme.bundleName)
733199
- );
733200
733238
  const toBeSyncedComponents = new Set(componentIds);
733201
733239
  const imageChecksums = fileLocks.filter(
733202
733240
  (fileLock) => fileLock.type === "image" && knownImages.has(fileLock.assetId)
733203
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733241
+ ).filter((fileLock) => checkFile(fileLocations.image[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733204
733242
  const iconChecksums = fileLocks.filter(
733205
733243
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "icon" && knownIcons.has(fileLock.assetId)
733206
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733244
+ ).filter((fileLock) => checkFile(fileLocations.icon[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733207
733245
  const renderModuleChecksums = fileLocks.filter(
733208
733246
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "renderModule" && toBeSyncedComponents.has(fileLock.assetId) && knownComponents.has(fileLock.assetId)
733247
+ ).filter(
733248
+ (fileLock) => checkFile(fileLocations.renderModule[fileLock.assetId])
733209
733249
  ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733210
733250
  const cssRulesChecksums = fileLocks.filter(
733211
733251
  (fileLock) => fileLock.type === "cssRules" && toBeSyncedComponents.has(fileLock.assetId) && knownComponents.has(fileLock.assetId)
733212
- ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733252
+ ).filter((fileLock) => checkFile(fileLocations.cssRules[fileLock.assetId])).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733213
733253
  const globalVariantChecksums = fileLocks.filter(
733214
733254
  (fileLock) => projectLock.lang === context.config.code.lang && fileLock.type === "globalVariant" && knownGlobalVariants.has(fileLock.assetId)
733255
+ ).filter(
733256
+ (fileLock) => checkFile(fileLocations.globalVariant[fileLock.assetId])
733215
733257
  ).map((fileLock) => [fileLock.assetId, fileLock.checksum]);
733216
- const projectCssChecksums = fileLocks.filter(
733217
- (fileLock) => fileLock.type === "projectCss"
733258
+ const projectCssChecksums = fileLocks.filter((fileLock) => fileLock.type === "projectCss").filter(
733259
+ (fileLock) => checkFile(fileLocations.projectCss[fileLock.assetId])
733218
733260
  );
733219
733261
  assert(projectCssChecksums.length < 2);
733220
733262
  const projectCssChecksum = projectCssChecksums.length > 0 ? projectCssChecksums[0].checksum : "";
733221
733263
  const globalContextsChecksums = fileLocks.filter(
733222
733264
  (fileLock) => fileLock.type === "globalContexts" && fileLock.assetId === projectId
733265
+ ).filter(
733266
+ (fileLock) => checkFile(fileLocations.globalContext[fileLock.assetId])
733223
733267
  );
733224
733268
  assert(globalContextsChecksums.length < 2);
733225
733269
  const globalContextsChecksum = globalContextsChecksums.length > 0 ? globalContextsChecksums[0].checksum : "";
@@ -734101,6 +734145,9 @@ async function sync(opts, metadataDefaults) {
734101
734145
  opts.baseDir = process.cwd();
734102
734146
  const baseDir = opts.baseDir;
734103
734147
  let context = await getContext(opts, { enableSkipAuth: true });
734148
+ if (opts.skipFormatting) {
734149
+ GLOBAL_SETTINGS.skipFormatting = true;
734150
+ }
734104
734151
  const isFirstRun = context.config.projects.length === 0;
734105
734152
  if (!opts.skipUpgradeCheck) {
734106
734153
  await ensureRequiredPackages(context, opts.baseDir, opts.yes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/cli",
3
- "version": "0.1.297",
3
+ "version": "0.1.299",
4
4
  "description": "plasmic cli for syncing local code with Plasmic designs",
5
5
  "engines": {
6
6
  "node": ">=12"
@@ -78,5 +78,5 @@
78
78
  "wrap-ansi": "^7.0.0",
79
79
  "yargs": "^15.4.1"
80
80
  },
81
- "gitHead": "a520ad6e43f967610882e50ee2731e03349eaa45"
81
+ "gitHead": "0397c260539c989f56c919436e57c48f1ad7a398"
82
82
  }
@@ -1,11 +1,17 @@
1
1
  import { CommonArgs } from "..";
2
+ import { GLOBAL_SETTINGS } from "../globals";
2
3
  import { fixAllImportStatements } from "../utils/code-utils";
3
4
  import { updateConfig } from "../utils/config-utils";
4
5
  import { getContext } from "../utils/get-context";
5
6
 
6
- export interface FixImportsArgs extends CommonArgs {}
7
+ export interface FixImportsArgs extends CommonArgs {
8
+ skipFormatting?: boolean;
9
+ }
7
10
  export async function fixImports(opts: FixImportsArgs) {
8
11
  if (!opts.baseDir) opts.baseDir = process.cwd();
12
+ if (opts.skipFormatting) {
13
+ GLOBAL_SETTINGS.skipFormatting = true;
14
+ }
9
15
  const context = await getContext(opts, { enableSkipAuth: true });
10
16
  await updateConfig(context, context.config, opts.baseDir);
11
17
  await fixAllImportStatements(context, opts.baseDir);
@@ -12,6 +12,7 @@ import {
12
12
  StyleConfigResponse,
13
13
  } from "../api";
14
14
  import { logger } from "../deps";
15
+ import { GLOBAL_SETTINGS } from "../globals";
15
16
  import { getChecksums } from "../utils/checksum";
16
17
  import {
17
18
  ComponentUpdateSummary,
@@ -21,12 +22,12 @@ import {
21
22
  } from "../utils/code-utils";
22
23
  import {
23
24
  CONFIG_FILE_NAME,
24
- createProjectConfig,
25
- getOrAddProjectConfig,
26
- getOrAddProjectLock,
27
25
  LOADER_CONFIG_FILE_NAME,
28
26
  PlasmicContext,
29
27
  PlasmicLoaderConfig,
28
+ createProjectConfig,
29
+ getOrAddProjectConfig,
30
+ getOrAddProjectLock,
30
31
  updateConfig,
31
32
  } from "../utils/config-utils";
32
33
  import { HandledError } from "../utils/error";
@@ -41,7 +42,7 @@ import {
41
42
  writeFileContent,
42
43
  writeFileText,
43
44
  } from "../utils/file-utils";
44
- import { generateMetadata, getContext, Metadata } from "../utils/get-context";
45
+ import { Metadata, generateMetadata, getContext } from "../utils/get-context";
45
46
  import { printFirstSyncInfo } from "../utils/help";
46
47
  import { ensure, tuple } from "../utils/lang-utils";
47
48
  import {
@@ -73,6 +74,7 @@ export interface SyncArgs extends CommonArgs {
73
74
  metadata?: string;
74
75
  allFiles?: boolean;
75
76
  loaderConfig?: string;
77
+ skipFormatting?: boolean;
76
78
  }
77
79
 
78
80
  async function ensureRequiredPackages(
@@ -198,6 +200,10 @@ export async function sync(
198
200
  const baseDir = opts.baseDir;
199
201
  let context = await getContext(opts, { enableSkipAuth: true });
200
202
 
203
+ if (opts.skipFormatting) {
204
+ GLOBAL_SETTINGS.skipFormatting = true;
205
+ }
206
+
201
207
  const isFirstRun = context.config.projects.length === 0;
202
208
 
203
209
  if (!opts.skipUpgradeCheck) {
package/src/globals.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const GLOBAL_SETTINGS = {
2
+ skipFormatting: false,
3
+ };
package/src/index.ts CHANGED
@@ -136,7 +136,12 @@ yargs
136
136
  .command<FixImportsArgs>(
137
137
  "fix-imports",
138
138
  "Fixes import paths after you've moved around Plasmic blackbox files",
139
- (yags) => 0,
139
+ (yags) =>
140
+ yags.option("skip-formatting", {
141
+ type: "boolean",
142
+ describe: "Skip formatting of modified code",
143
+ default: false,
144
+ }),
140
145
  (argv) => handleError(fixImports(argv))
141
146
  )
142
147
  .command<InfoArgs>(
@@ -345,6 +350,11 @@ function configureSyncArgs(
345
350
  default: "source=cli",
346
351
  hidden: true,
347
352
  })
353
+ .option("skip-formatting", {
354
+ type: "boolean",
355
+ describe: "Disables formatting on generated code",
356
+ default: false,
357
+ })
348
358
  .option("all-files", {
349
359
  type: "boolean",
350
360
  describe:
@@ -1,8 +1,38 @@
1
1
  import { SyncArgs } from "../actions/sync";
2
2
  import { ChecksumBundle } from "../api";
3
- import { PlasmicContext } from "./config-utils";
3
+ import { PlasmicContext, ProjectConfig } from "./config-utils";
4
+ import { fileExists } from "./file-utils";
4
5
  import { assert } from "./lang-utils";
5
6
 
7
+ function getFilesByFileLockAssetId(
8
+ context: PlasmicContext,
9
+ projectConfig: ProjectConfig
10
+ ) {
11
+ return {
12
+ renderModule: Object.fromEntries(
13
+ projectConfig.components.map((c) => [c.id, c.renderModuleFilePath])
14
+ ),
15
+ cssRules: Object.fromEntries(
16
+ projectConfig.components.map((c) => [c.id, c.cssFilePath])
17
+ ),
18
+ icon: Object.fromEntries(
19
+ projectConfig.icons.map((i) => [i.id, i.moduleFilePath])
20
+ ),
21
+ image: Object.fromEntries(
22
+ projectConfig.images.map((i) => [i.id, i.filePath])
23
+ ),
24
+ projectCss: { [projectConfig.projectId]: projectConfig.cssFilePath },
25
+ globalVariant: Object.fromEntries(
26
+ context.config.globalVariants.variantGroups
27
+ .filter((vg) => vg.projectId === projectConfig.projectId)
28
+ .map((vg) => [vg.id, vg.contextFilePath])
29
+ ),
30
+ globalContext: {
31
+ [projectConfig.projectId]: projectConfig.globalContextsFilePath,
32
+ },
33
+ } as const;
34
+ }
35
+
6
36
  export function getChecksums(
7
37
  context: PlasmicContext,
8
38
  opts: SyncArgs,
@@ -29,6 +59,15 @@ export function getChecksums(
29
59
  };
30
60
  }
31
61
 
62
+ // We only use checksum for files that actually exist on disk
63
+ const fileLocations = getFilesByFileLockAssetId(context, projectConfig);
64
+ const checkFile = (file: string | undefined) => {
65
+ if (!file) {
66
+ return false;
67
+ }
68
+ return fileExists(context, file);
69
+ };
70
+
32
71
  const fileLocks = projectLock.fileLocks;
33
72
 
34
73
  const knownImages = new Set(projectConfig.images.map((i) => i.id));
@@ -39,9 +78,6 @@ export function getChecksums(
39
78
  .filter((vg) => vg.projectId === projectId)
40
79
  .map((vg) => vg.id)
41
80
  );
42
- const knownThemes = new Set(
43
- (projectConfig.jsBundleThemes || []).map((theme) => theme.bundleName)
44
- );
45
81
 
46
82
  const toBeSyncedComponents = new Set(componentIds);
47
83
 
@@ -50,6 +86,7 @@ export function getChecksums(
50
86
  (fileLock) =>
51
87
  fileLock.type === "image" && knownImages.has(fileLock.assetId)
52
88
  )
89
+ .filter((fileLock) => checkFile(fileLocations.image[fileLock.assetId]))
53
90
  .map((fileLock): [string, string] => [fileLock.assetId, fileLock.checksum]);
54
91
 
55
92
  const iconChecksums = fileLocks
@@ -59,6 +96,7 @@ export function getChecksums(
59
96
  fileLock.type === "icon" &&
60
97
  knownIcons.has(fileLock.assetId)
61
98
  )
99
+ .filter((fileLock) => checkFile(fileLocations.icon[fileLock.assetId]))
62
100
  .map((fileLock): [string, string] => [fileLock.assetId, fileLock.checksum]);
63
101
 
64
102
  const renderModuleChecksums = fileLocks
@@ -69,6 +107,9 @@ export function getChecksums(
69
107
  toBeSyncedComponents.has(fileLock.assetId) &&
70
108
  knownComponents.has(fileLock.assetId)
71
109
  )
110
+ .filter((fileLock) =>
111
+ checkFile(fileLocations.renderModule[fileLock.assetId])
112
+ )
72
113
  .map((fileLock): [string, string] => [fileLock.assetId, fileLock.checksum]);
73
114
 
74
115
  const cssRulesChecksums = fileLocks
@@ -78,6 +119,7 @@ export function getChecksums(
78
119
  toBeSyncedComponents.has(fileLock.assetId) &&
79
120
  knownComponents.has(fileLock.assetId)
80
121
  )
122
+ .filter((fileLock) => checkFile(fileLocations.cssRules[fileLock.assetId]))
81
123
  .map((fileLock): [string, string] => [fileLock.assetId, fileLock.checksum]);
82
124
 
83
125
  const globalVariantChecksums = fileLocks
@@ -87,19 +129,28 @@ export function getChecksums(
87
129
  fileLock.type === "globalVariant" &&
88
130
  knownGlobalVariants.has(fileLock.assetId)
89
131
  )
132
+ .filter((fileLock) =>
133
+ checkFile(fileLocations.globalVariant[fileLock.assetId])
134
+ )
90
135
  .map((fileLock): [string, string] => [fileLock.assetId, fileLock.checksum]);
91
136
 
92
- const projectCssChecksums = fileLocks.filter(
93
- (fileLock) => fileLock.type === "projectCss"
94
- );
137
+ const projectCssChecksums = fileLocks
138
+ .filter((fileLock) => fileLock.type === "projectCss")
139
+ .filter((fileLock) =>
140
+ checkFile(fileLocations.projectCss[fileLock.assetId])
141
+ );
95
142
  assert(projectCssChecksums.length < 2);
96
143
  const projectCssChecksum =
97
144
  projectCssChecksums.length > 0 ? projectCssChecksums[0].checksum : "";
98
145
 
99
- const globalContextsChecksums = fileLocks.filter(
100
- (fileLock) =>
101
- fileLock.type === "globalContexts" && fileLock.assetId === projectId
102
- );
146
+ const globalContextsChecksums = fileLocks
147
+ .filter(
148
+ (fileLock) =>
149
+ fileLock.type === "globalContexts" && fileLock.assetId === projectId
150
+ )
151
+ .filter((fileLock) =>
152
+ checkFile(fileLocations.globalContext[fileLock.assetId])
153
+ );
103
154
  assert(globalContextsChecksums.length < 2);
104
155
  const globalContextsChecksum =
105
156
  globalContextsChecksums.length > 0
@@ -34,6 +34,7 @@ import {
34
34
  writeFileContent,
35
35
  } from "./file-utils";
36
36
  import { assert, flatMap } from "./lang-utils";
37
+ import { GLOBAL_SETTINGS } from "../globals";
37
38
 
38
39
  export const formatAsLocal = (
39
40
  content: string,
@@ -41,6 +42,9 @@ export const formatAsLocal = (
41
42
  baseDir: string,
42
43
  defaultOpts: Options = {}
43
44
  ) => {
45
+ if (GLOBAL_SETTINGS.skipFormatting) {
46
+ return content;
47
+ }
44
48
  // TODO: we used to use resolveConfig.sync() to try to use local prettier,
45
49
  // but this ended up using unrelated prettier config higher up the stack,
46
50
  // which dangerously may remove unused imports like