@plasmicapp/cli 0.1.300 → 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 +41 -11
- package/dist/lib.js +37 -11
- package/package.json +2 -2
- package/src/actions/sync.ts +10 -3
- package/src/index.ts +6 -0
- package/src/utils/auth-utils.ts +6 -1
- 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) {
|
|
@@ -736636,7 +736654,10 @@ async function startAuth(opts) {
|
|
|
736636
736654
|
let prompt;
|
|
736637
736655
|
const initToken = v4_default();
|
|
736638
736656
|
const url = `${opts.host}/auth/plasmic-init/${initToken}`;
|
|
736639
|
-
(0, import_open.default)(url)
|
|
736657
|
+
(0, import_open.default)(url).then((subprocess) => {
|
|
736658
|
+
subprocess.on("error", () => {
|
|
736659
|
+
});
|
|
736660
|
+
});
|
|
736640
736661
|
logger.info(
|
|
736641
736662
|
`
|
|
736642
736663
|
If your browser doesn't automatically open, enter the following URL:
|
|
@@ -738940,7 +738961,7 @@ async function sync(opts, metadataDefaults) {
|
|
|
738940
738961
|
context.api.attachProjectIdsAndTokens(projectIdsAndTokens);
|
|
738941
738962
|
const externalNpmPackages = /* @__PURE__ */ new Set();
|
|
738942
738963
|
const externalCssImports = /* @__PURE__ */ new Set();
|
|
738943
|
-
|
|
738964
|
+
const doSync = async () => {
|
|
738944
738965
|
var _a2;
|
|
738945
738966
|
for (const projectMeta of projectsToSync) {
|
|
738946
738967
|
await syncProject(
|
|
@@ -739009,7 +739030,12 @@ async function sync(opts, metadataDefaults) {
|
|
|
739009
739030
|
}
|
|
739010
739031
|
});
|
|
739011
739032
|
await updateConfig(context, context.config, baseDir);
|
|
739012
|
-
}
|
|
739033
|
+
};
|
|
739034
|
+
if (opts.skipBuffering) {
|
|
739035
|
+
await doSync();
|
|
739036
|
+
} else {
|
|
739037
|
+
await withBufferedFs(doSync);
|
|
739038
|
+
}
|
|
739013
739039
|
await checkExternalPkgs(
|
|
739014
739040
|
context,
|
|
739015
739041
|
baseDir,
|
|
@@ -739775,6 +739801,10 @@ function configureSyncArgs(yags, includeQuietOption = true) {
|
|
|
739775
739801
|
type: "boolean",
|
|
739776
739802
|
describe: "Disables formatting on generated code",
|
|
739777
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
|
|
739778
739808
|
}).option("all-files", {
|
|
739779
739809
|
type: "boolean",
|
|
739780
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) {
|
|
@@ -731976,7 +731994,10 @@ async function startAuth(opts) {
|
|
|
731976
731994
|
let prompt;
|
|
731977
731995
|
const initToken = v4_default();
|
|
731978
731996
|
const url = `${opts.host}/auth/plasmic-init/${initToken}`;
|
|
731979
|
-
(0, import_open.default)(url)
|
|
731997
|
+
(0, import_open.default)(url).then((subprocess) => {
|
|
731998
|
+
subprocess.on("error", () => {
|
|
731999
|
+
});
|
|
732000
|
+
});
|
|
731980
732001
|
logger.info(
|
|
731981
732002
|
`
|
|
731982
732003
|
If your browser doesn't automatically open, enter the following URL:
|
|
@@ -734236,7 +734257,7 @@ async function sync(opts, metadataDefaults) {
|
|
|
734236
734257
|
context.api.attachProjectIdsAndTokens(projectIdsAndTokens);
|
|
734237
734258
|
const externalNpmPackages = /* @__PURE__ */ new Set();
|
|
734238
734259
|
const externalCssImports = /* @__PURE__ */ new Set();
|
|
734239
|
-
|
|
734260
|
+
const doSync = async () => {
|
|
734240
734261
|
var _a2;
|
|
734241
734262
|
for (const projectMeta of projectsToSync) {
|
|
734242
734263
|
await syncProject(
|
|
@@ -734305,7 +734326,12 @@ async function sync(opts, metadataDefaults) {
|
|
|
734305
734326
|
}
|
|
734306
734327
|
});
|
|
734307
734328
|
await updateConfig(context, context.config, baseDir);
|
|
734308
|
-
}
|
|
734329
|
+
};
|
|
734330
|
+
if (opts.skipBuffering) {
|
|
734331
|
+
await doSync();
|
|
734332
|
+
} else {
|
|
734333
|
+
await withBufferedFs(doSync);
|
|
734334
|
+
}
|
|
734309
734335
|
await checkExternalPkgs(
|
|
734310
734336
|
context,
|
|
734311
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/auth-utils.ts
CHANGED
|
@@ -102,7 +102,12 @@ export async function startAuth(opts: Partial<CommonArgs> & { host: string }) {
|
|
|
102
102
|
|
|
103
103
|
const initToken = uuidv4();
|
|
104
104
|
const url = `${opts.host}/auth/plasmic-init/${initToken}`;
|
|
105
|
-
open(url)
|
|
105
|
+
open(url).then((subprocess) => {
|
|
106
|
+
subprocess.on("error", () => {
|
|
107
|
+
// Browser failed to start. This needs to be handled to avoid
|
|
108
|
+
// crashing the CLI.
|
|
109
|
+
});
|
|
110
|
+
});
|
|
106
111
|
logger.info(
|
|
107
112
|
`\nIf your browser doesn't automatically open, enter the following URL:\n${url}\n`
|
|
108
113
|
);
|
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(
|