@plasmicapp/cli 0.1.301 → 0.1.302
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.
- package/dist/actions/sync.d.ts +1 -0
- package/dist/index.js +37 -10
- package/dist/lib.js +33 -10
- package/package.json +2 -2
- package/src/actions/sync.ts +10 -3
- package/src/index.ts +6 -0
- package/src/utils/code-utils.ts +28 -8
package/dist/actions/sync.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface SyncArgs extends CommonArgs {
|
|
|
13
13
|
allFiles?: boolean;
|
|
14
14
|
loaderConfig?: string;
|
|
15
15
|
skipFormatting?: boolean;
|
|
16
|
+
skipBuffering?: boolean;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Sync will always try to sync down a set of components that are version-consistent among specified projects.
|
package/dist/index.js
CHANGED
|
@@ -735439,6 +735439,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
|
|
|
735439
735439
|
logger.info("Fixing import statements...");
|
|
735440
735440
|
const config = context.config;
|
|
735441
735441
|
const fixImportContext = mkFixImportContext(config);
|
|
735442
|
+
let lastError = void 0;
|
|
735442
735443
|
for (const project of config.projects) {
|
|
735443
735444
|
for (const compConfig of project.components) {
|
|
735444
735445
|
const compSummary = summary == null ? void 0 : summary.get(compConfig.id);
|
|
@@ -735447,17 +735448,34 @@ async function fixAllImportStatements(context, baseDir, summary) {
|
|
|
735447
735448
|
}
|
|
735448
735449
|
const fixSkeletonModule = compSummary ? compSummary.skeletonModuleModified : true;
|
|
735449
735450
|
if (!summary || compSummary) {
|
|
735450
|
-
|
|
735451
|
-
|
|
735452
|
-
|
|
735453
|
-
|
|
735454
|
-
|
|
735455
|
-
|
|
735456
|
-
|
|
735451
|
+
try {
|
|
735452
|
+
await fixComponentImportStatements(
|
|
735453
|
+
context,
|
|
735454
|
+
compConfig,
|
|
735455
|
+
fixImportContext,
|
|
735456
|
+
fixSkeletonModule,
|
|
735457
|
+
baseDir
|
|
735458
|
+
);
|
|
735459
|
+
} catch (err) {
|
|
735460
|
+
logger.error(
|
|
735461
|
+
`Error encountered while fixing imports for ${compConfig.name}: ${err}`
|
|
735462
|
+
);
|
|
735463
|
+
lastError = err;
|
|
735464
|
+
}
|
|
735457
735465
|
}
|
|
735458
735466
|
}
|
|
735459
735467
|
}
|
|
735460
|
-
|
|
735468
|
+
try {
|
|
735469
|
+
fixGlobalContextImportStatements(context, fixImportContext, baseDir);
|
|
735470
|
+
} catch (err) {
|
|
735471
|
+
logger.error(
|
|
735472
|
+
`Error encountered while fixing imports for global contexts: ${err}`
|
|
735473
|
+
);
|
|
735474
|
+
lastError = err;
|
|
735475
|
+
}
|
|
735476
|
+
if (lastError) {
|
|
735477
|
+
throw lastError;
|
|
735478
|
+
}
|
|
735461
735479
|
}
|
|
735462
735480
|
async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule, baseDir) {
|
|
735463
735481
|
if (compConfig.type !== "mapped" && isLocalModulePath(compConfig.importSpec.modulePath) && fixSkeletonModule) {
|
|
@@ -738943,7 +738961,7 @@ async function sync(opts, metadataDefaults) {
|
|
|
738943
738961
|
context.api.attachProjectIdsAndTokens(projectIdsAndTokens);
|
|
738944
738962
|
const externalNpmPackages = /* @__PURE__ */ new Set();
|
|
738945
738963
|
const externalCssImports = /* @__PURE__ */ new Set();
|
|
738946
|
-
|
|
738964
|
+
const doSync = async () => {
|
|
738947
738965
|
var _a2;
|
|
738948
738966
|
for (const projectMeta of projectsToSync) {
|
|
738949
738967
|
await syncProject(
|
|
@@ -739012,7 +739030,12 @@ async function sync(opts, metadataDefaults) {
|
|
|
739012
739030
|
}
|
|
739013
739031
|
});
|
|
739014
739032
|
await updateConfig(context, context.config, baseDir);
|
|
739015
|
-
}
|
|
739033
|
+
};
|
|
739034
|
+
if (opts.skipBuffering) {
|
|
739035
|
+
await doSync();
|
|
739036
|
+
} else {
|
|
739037
|
+
await withBufferedFs(doSync);
|
|
739038
|
+
}
|
|
739016
739039
|
await checkExternalPkgs(
|
|
739017
739040
|
context,
|
|
739018
739041
|
baseDir,
|
|
@@ -739778,6 +739801,10 @@ function configureSyncArgs(yags, includeQuietOption = true) {
|
|
|
739778
739801
|
type: "boolean",
|
|
739779
739802
|
describe: "Disables formatting on generated code",
|
|
739780
739803
|
default: false
|
|
739804
|
+
}).option("skip-buffering", {
|
|
739805
|
+
type: "boolean",
|
|
739806
|
+
describe: "Write files directly to disk, instead of buffering and only writing if sync completes successfully",
|
|
739807
|
+
default: false
|
|
739781
739808
|
}).option("all-files", {
|
|
739782
739809
|
type: "boolean",
|
|
739783
739810
|
describe: "Sync all files, including those that haven't changed since last sync",
|
package/dist/lib.js
CHANGED
|
@@ -730779,6 +730779,7 @@ async function fixAllImportStatements(context, baseDir, summary) {
|
|
|
730779
730779
|
logger.info("Fixing import statements...");
|
|
730780
730780
|
const config = context.config;
|
|
730781
730781
|
const fixImportContext = mkFixImportContext(config);
|
|
730782
|
+
let lastError = void 0;
|
|
730782
730783
|
for (const project of config.projects) {
|
|
730783
730784
|
for (const compConfig of project.components) {
|
|
730784
730785
|
const compSummary = summary == null ? void 0 : summary.get(compConfig.id);
|
|
@@ -730787,17 +730788,34 @@ async function fixAllImportStatements(context, baseDir, summary) {
|
|
|
730787
730788
|
}
|
|
730788
730789
|
const fixSkeletonModule = compSummary ? compSummary.skeletonModuleModified : true;
|
|
730789
730790
|
if (!summary || compSummary) {
|
|
730790
|
-
|
|
730791
|
-
|
|
730792
|
-
|
|
730793
|
-
|
|
730794
|
-
|
|
730795
|
-
|
|
730796
|
-
|
|
730791
|
+
try {
|
|
730792
|
+
await fixComponentImportStatements(
|
|
730793
|
+
context,
|
|
730794
|
+
compConfig,
|
|
730795
|
+
fixImportContext,
|
|
730796
|
+
fixSkeletonModule,
|
|
730797
|
+
baseDir
|
|
730798
|
+
);
|
|
730799
|
+
} catch (err) {
|
|
730800
|
+
logger.error(
|
|
730801
|
+
`Error encountered while fixing imports for ${compConfig.name}: ${err}`
|
|
730802
|
+
);
|
|
730803
|
+
lastError = err;
|
|
730804
|
+
}
|
|
730797
730805
|
}
|
|
730798
730806
|
}
|
|
730799
730807
|
}
|
|
730800
|
-
|
|
730808
|
+
try {
|
|
730809
|
+
fixGlobalContextImportStatements(context, fixImportContext, baseDir);
|
|
730810
|
+
} catch (err) {
|
|
730811
|
+
logger.error(
|
|
730812
|
+
`Error encountered while fixing imports for global contexts: ${err}`
|
|
730813
|
+
);
|
|
730814
|
+
lastError = err;
|
|
730815
|
+
}
|
|
730816
|
+
if (lastError) {
|
|
730817
|
+
throw lastError;
|
|
730818
|
+
}
|
|
730801
730819
|
}
|
|
730802
730820
|
async function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule, baseDir) {
|
|
730803
730821
|
if (compConfig.type !== "mapped" && isLocalModulePath(compConfig.importSpec.modulePath) && fixSkeletonModule) {
|
|
@@ -734239,7 +734257,7 @@ async function sync(opts, metadataDefaults) {
|
|
|
734239
734257
|
context.api.attachProjectIdsAndTokens(projectIdsAndTokens);
|
|
734240
734258
|
const externalNpmPackages = /* @__PURE__ */ new Set();
|
|
734241
734259
|
const externalCssImports = /* @__PURE__ */ new Set();
|
|
734242
|
-
|
|
734260
|
+
const doSync = async () => {
|
|
734243
734261
|
var _a2;
|
|
734244
734262
|
for (const projectMeta of projectsToSync) {
|
|
734245
734263
|
await syncProject(
|
|
@@ -734308,7 +734326,12 @@ async function sync(opts, metadataDefaults) {
|
|
|
734308
734326
|
}
|
|
734309
734327
|
});
|
|
734310
734328
|
await updateConfig(context, context.config, baseDir);
|
|
734311
|
-
}
|
|
734329
|
+
};
|
|
734330
|
+
if (opts.skipBuffering) {
|
|
734331
|
+
await doSync();
|
|
734332
|
+
} else {
|
|
734333
|
+
await withBufferedFs(doSync);
|
|
734334
|
+
}
|
|
734312
734335
|
await checkExternalPkgs(
|
|
734313
734336
|
context,
|
|
734314
734337
|
baseDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.302",
|
|
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": "
|
|
81
|
+
"gitHead": "98f55a13c36ec563fe7e8f286167d0c3f241fee8"
|
|
82
82
|
}
|
package/src/actions/sync.ts
CHANGED
|
@@ -75,6 +75,7 @@ export interface SyncArgs extends CommonArgs {
|
|
|
75
75
|
allFiles?: boolean;
|
|
76
76
|
loaderConfig?: string;
|
|
77
77
|
skipFormatting?: boolean;
|
|
78
|
+
skipBuffering?: boolean;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
async function ensureRequiredPackages(
|
|
@@ -319,8 +320,7 @@ export async function sync(
|
|
|
319
320
|
const externalNpmPackages = new Set<string>();
|
|
320
321
|
const externalCssImports = new Set<string>();
|
|
321
322
|
|
|
322
|
-
|
|
323
|
-
await withBufferedFs(async () => {
|
|
323
|
+
const doSync = async () => {
|
|
324
324
|
// Sync in sequence (no parallelism)
|
|
325
325
|
// going in reverse to get leaves of the dependency tree first
|
|
326
326
|
for (const projectMeta of projectsToSync) {
|
|
@@ -408,7 +408,14 @@ export async function sync(
|
|
|
408
408
|
});
|
|
409
409
|
// Write the new ComponentConfigs to disk
|
|
410
410
|
await updateConfig(context, context.config, baseDir);
|
|
411
|
-
}
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// Perform the actual sync
|
|
414
|
+
if (opts.skipBuffering) {
|
|
415
|
+
await doSync();
|
|
416
|
+
} else {
|
|
417
|
+
await withBufferedFs(doSync);
|
|
418
|
+
}
|
|
412
419
|
|
|
413
420
|
await checkExternalPkgs(
|
|
414
421
|
context,
|
package/src/index.ts
CHANGED
|
@@ -366,6 +366,12 @@ function configureSyncArgs(
|
|
|
366
366
|
describe: "Disables formatting on generated code",
|
|
367
367
|
default: false,
|
|
368
368
|
})
|
|
369
|
+
.option("skip-buffering", {
|
|
370
|
+
type: "boolean",
|
|
371
|
+
describe:
|
|
372
|
+
"Write files directly to disk, instead of buffering and only writing if sync completes successfully",
|
|
373
|
+
default: false,
|
|
374
|
+
})
|
|
369
375
|
.option("all-files", {
|
|
370
376
|
type: "boolean",
|
|
371
377
|
describe:
|
package/src/utils/code-utils.ts
CHANGED
|
@@ -504,6 +504,7 @@ export async function fixAllImportStatements(
|
|
|
504
504
|
logger.info("Fixing import statements...");
|
|
505
505
|
const config = context.config;
|
|
506
506
|
const fixImportContext = mkFixImportContext(config);
|
|
507
|
+
let lastError: any = undefined;
|
|
507
508
|
for (const project of config.projects) {
|
|
508
509
|
for (const compConfig of project.components) {
|
|
509
510
|
const compSummary = summary?.get(compConfig.id);
|
|
@@ -514,17 +515,36 @@ export async function fixAllImportStatements(
|
|
|
514
515
|
? compSummary.skeletonModuleModified
|
|
515
516
|
: true;
|
|
516
517
|
if (!summary || compSummary) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
518
|
+
try {
|
|
519
|
+
await fixComponentImportStatements(
|
|
520
|
+
context,
|
|
521
|
+
compConfig,
|
|
522
|
+
fixImportContext,
|
|
523
|
+
fixSkeletonModule,
|
|
524
|
+
baseDir
|
|
525
|
+
);
|
|
526
|
+
} catch (err) {
|
|
527
|
+
logger.error(
|
|
528
|
+
`Error encountered while fixing imports for ${compConfig.name}: ${err}`
|
|
529
|
+
);
|
|
530
|
+
lastError = err;
|
|
531
|
+
}
|
|
524
532
|
}
|
|
525
533
|
}
|
|
526
534
|
}
|
|
527
|
-
|
|
535
|
+
|
|
536
|
+
try {
|
|
537
|
+
fixGlobalContextImportStatements(context, fixImportContext, baseDir);
|
|
538
|
+
} catch (err) {
|
|
539
|
+
logger.error(
|
|
540
|
+
`Error encountered while fixing imports for global contexts: ${err}`
|
|
541
|
+
);
|
|
542
|
+
lastError = err;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (lastError) {
|
|
546
|
+
throw lastError;
|
|
547
|
+
}
|
|
528
548
|
}
|
|
529
549
|
|
|
530
550
|
async function fixComponentImportStatements(
|