@plasmicapp/cli 0.1.293 → 0.1.295
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/__mocks__/api.js +10 -6
- package/dist/__tests__/code-utils-spec.js +12 -12
- package/dist/__tests__/file-utils.spec.js +11 -11
- package/dist/__tests__/ftue-spec.js +7 -7
- package/dist/__tests__/project-api-token-spec.js +33 -33
- package/dist/__tests__/versioned-sync-spec.js +20 -20
- package/dist/actions/auth.d.ts +1 -1
- package/dist/actions/auth.js +3 -3
- package/dist/actions/fix-imports.js +3 -3
- package/dist/actions/info.js +1 -1
- package/dist/actions/init.js +28 -28
- package/dist/actions/localization-strings.js +34 -26
- package/dist/actions/project-token.d.ts +1 -1
- package/dist/actions/project-token.js +6 -4
- package/dist/actions/sync-components.js +29 -29
- package/dist/actions/sync-global-contexts.js +5 -5
- package/dist/actions/sync-global-variants.js +9 -9
- package/dist/actions/sync-icons.js +10 -10
- package/dist/actions/sync-images.js +20 -20
- package/dist/actions/sync-styles.js +4 -4
- package/dist/actions/sync.js +52 -48
- package/dist/actions/upload-bundle.js +4 -4
- package/dist/actions/watch.js +10 -6
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/deps.js +2 -0
- package/dist/index.js +28 -24
- package/dist/lib.js +1 -0
- package/dist/migrations/0.1.28-tsToTsx.js +3 -3
- package/dist/migrations/migrations.d.ts +2 -2
- package/dist/migrations/migrations.js +12 -12
- package/dist/plasmic.schema.json +3 -2
- package/dist/utils/auth-utils.d.ts +2 -2
- package/dist/utils/auth-utils.js +8 -8
- package/dist/utils/checksum.js +2 -2
- package/dist/utils/code-utils.js +40 -32
- package/dist/utils/config-utils.d.ts +3 -3
- package/dist/utils/config-utils.js +5 -5
- package/dist/utils/envdetect.js +8 -8
- package/dist/utils/error.js +3 -2
- package/dist/utils/file-utils.js +3 -3
- package/dist/utils/get-context.js +20 -16
- package/dist/utils/help.js +2 -2
- package/dist/utils/lang-utils.d.ts +1 -1
- package/dist/utils/lang-utils.js +2 -1
- package/dist/utils/npm-utils.js +18 -16
- package/dist/utils/resolve-utils.js +11 -7
- package/dist/utils/semver.d.ts +2 -2
- package/dist/utils/semver.js +64 -35
- package/dist/utils/test-utils.js +9 -5
- package/package.json +5 -5
- package/src/actions/init.ts +2 -2
- package/src/actions/localization-strings.ts +34 -21
- package/src/index.ts +1 -1
- package/src/utils/config-utils.ts +3 -3
package/dist/utils/envdetect.js
CHANGED
|
@@ -7,17 +7,17 @@ exports.detectCreateReactApp = exports.detectGatsby = exports.detectNextJsAppDir
|
|
|
7
7
|
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
8
8
|
const npm_utils_1 = require("./npm-utils");
|
|
9
9
|
function detectTypescript() {
|
|
10
|
-
return findup_sync_1.default("tsconfig.json");
|
|
10
|
+
return (0, findup_sync_1.default)("tsconfig.json");
|
|
11
11
|
}
|
|
12
12
|
exports.detectTypescript = detectTypescript;
|
|
13
13
|
function detectNextJs() {
|
|
14
|
-
if (findup_sync_1.default("next.config.js") ||
|
|
15
|
-
findup_sync_1.default(".next") ||
|
|
16
|
-
findup_sync_1.default("next-env.d.ts")) {
|
|
14
|
+
if ((0, findup_sync_1.default)("next.config.js") ||
|
|
15
|
+
(0, findup_sync_1.default)(".next") ||
|
|
16
|
+
(0, findup_sync_1.default)("next-env.d.ts")) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
|
-
const packageJsonContent = npm_utils_1.getParsedPackageJson();
|
|
20
|
+
const packageJsonContent = (0, npm_utils_1.getParsedPackageJson)();
|
|
21
21
|
return (packageJsonContent.scripts.build === "next build" ||
|
|
22
22
|
"next" in packageJsonContent.dependencies);
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ function detectNextJs() {
|
|
|
28
28
|
exports.detectNextJs = detectNextJs;
|
|
29
29
|
function detectNextJsAppDir() {
|
|
30
30
|
var _a, _b;
|
|
31
|
-
const nextConfigPath = findup_sync_1.default("next.config.js");
|
|
31
|
+
const nextConfigPath = (0, findup_sync_1.default)("next.config.js");
|
|
32
32
|
if (!nextConfigPath) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
@@ -36,12 +36,12 @@ function detectNextJsAppDir() {
|
|
|
36
36
|
}
|
|
37
37
|
exports.detectNextJsAppDir = detectNextJsAppDir;
|
|
38
38
|
function detectGatsby() {
|
|
39
|
-
return findup_sync_1.default("gatsby-config.js") || findup_sync_1.default("gatsby-config.ts");
|
|
39
|
+
return (0, findup_sync_1.default)("gatsby-config.js") || (0, findup_sync_1.default)("gatsby-config.ts");
|
|
40
40
|
}
|
|
41
41
|
exports.detectGatsby = detectGatsby;
|
|
42
42
|
function detectCreateReactApp() {
|
|
43
43
|
try {
|
|
44
|
-
const packageJsonContent = npm_utils_1.getParsedPackageJson();
|
|
44
|
+
const packageJsonContent = (0, npm_utils_1.getParsedPackageJson)();
|
|
45
45
|
return "react-scripts" in packageJsonContent.dependencies;
|
|
46
46
|
}
|
|
47
47
|
catch (_a) {
|
package/dist/utils/error.js
CHANGED
|
@@ -21,13 +21,13 @@ exports.HandledError = HandledError;
|
|
|
21
21
|
* @param p
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const handleError = (p) => {
|
|
25
25
|
return p.catch((e) => {
|
|
26
26
|
if (e.message) {
|
|
27
27
|
deps_1.logger.error(chalk_1.default.bold(chalk_1.default.redBright("\nPlasmic error: ")) + e.message);
|
|
28
28
|
}
|
|
29
29
|
// Check if we satisfy the engine policy first
|
|
30
|
-
if (npm_utils_1.checkEngineStrict()) {
|
|
30
|
+
if ((0, npm_utils_1.checkEngineStrict)()) {
|
|
31
31
|
// eslint-disable-next-line
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
@@ -40,3 +40,4 @@ exports.handleError = (p) => {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
|
+
exports.handleError = handleError;
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -38,7 +38,7 @@ function writeFileContentRaw(filePath, content, opts) {
|
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
39
|
opts = opts || {};
|
|
40
40
|
if (existsBuffered(filePath) && !opts.force) {
|
|
41
|
-
const overwrite = yield user_utils_1.confirmWithUser(`File ${filePath} already exists. Do you want to overwrite?`, opts.yes);
|
|
41
|
+
const overwrite = yield (0, user_utils_1.confirmWithUser)(`File ${filePath} already exists. Do you want to overwrite?`, opts.yes);
|
|
42
42
|
if (!overwrite) {
|
|
43
43
|
throw new error_1.HandledError(`Cannot write to ${filePath}; file already exists.`);
|
|
44
44
|
}
|
|
@@ -228,7 +228,7 @@ function getAllPaths(context) {
|
|
|
228
228
|
const pushComponent = (comp) => {
|
|
229
229
|
pushPath(comp, "renderModuleFilePath");
|
|
230
230
|
pushPath(comp, "cssFilePath");
|
|
231
|
-
if (code_utils_1.isLocalModulePath(comp.importSpec.modulePath)) {
|
|
231
|
+
if ((0, code_utils_1.isLocalModulePath)(comp.importSpec.modulePath)) {
|
|
232
232
|
pushPath(comp.importSpec, "modulePath");
|
|
233
233
|
}
|
|
234
234
|
};
|
|
@@ -351,7 +351,7 @@ function readFileText(path) {
|
|
|
351
351
|
if (action) {
|
|
352
352
|
switch (action.type) {
|
|
353
353
|
case "create":
|
|
354
|
-
return lang_utils_1.ensureString(action.content);
|
|
354
|
+
return (0, lang_utils_1.ensureString)(action.content);
|
|
355
355
|
case "rename":
|
|
356
356
|
return readFileText(action.newPath);
|
|
357
357
|
case "delete":
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -50,15 +54,15 @@ const prompts = __importStar(require("./prompts"));
|
|
|
50
54
|
function createPlasmicLock() {
|
|
51
55
|
return {
|
|
52
56
|
projects: [],
|
|
53
|
-
cliVersion: npm_utils_1.getCliVersion(),
|
|
57
|
+
cliVersion: (0, npm_utils_1.getCliVersion)(),
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
function readLock(lockFile) {
|
|
57
|
-
if (!file_utils_1.existsBuffered(lockFile)) {
|
|
61
|
+
if (!(0, file_utils_1.existsBuffered)(lockFile)) {
|
|
58
62
|
return createPlasmicLock();
|
|
59
63
|
}
|
|
60
64
|
try {
|
|
61
|
-
const result = JSON.parse(file_utils_1.readFileText(lockFile));
|
|
65
|
+
const result = JSON.parse((0, file_utils_1.readFileText)(lockFile));
|
|
62
66
|
return Object.assign({}, result);
|
|
63
67
|
}
|
|
64
68
|
catch (e) {
|
|
@@ -118,7 +122,7 @@ function attemptToRestoreFilePath(context, expectedPath, baseNameToFiles) {
|
|
|
118
122
|
if (expectedPath === "") {
|
|
119
123
|
return undefined;
|
|
120
124
|
}
|
|
121
|
-
if (file_utils_1.fileExists(context, expectedPath)) {
|
|
125
|
+
if ((0, file_utils_1.fileExists)(context, expectedPath)) {
|
|
122
126
|
return expectedPath;
|
|
123
127
|
}
|
|
124
128
|
const fileName = upath_1.default.basename(expectedPath);
|
|
@@ -155,7 +159,7 @@ function attemptToRestoreFilePath(context, expectedPath, baseNameToFiles) {
|
|
|
155
159
|
}
|
|
156
160
|
function resolveMissingFilesInConfig(context, config) {
|
|
157
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
const baseNameToFiles = file_utils_1.buildBaseNameToFiles(context);
|
|
162
|
+
const baseNameToFiles = (0, file_utils_1.buildBaseNameToFiles)(context);
|
|
159
163
|
// Make sure all the files exist. Prompt the user / exit process if not.
|
|
160
164
|
function filterFiles(list, pathProp) {
|
|
161
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -234,16 +238,16 @@ function getContext(args, { enableSkipAuth = false } = {}) {
|
|
|
234
238
|
if (auth.user) {
|
|
235
239
|
scope.setUser({ email: auth.user });
|
|
236
240
|
}
|
|
237
|
-
scope.setExtra("cliVersion", npm_utils_1.getCliVersion());
|
|
241
|
+
scope.setExtra("cliVersion", (0, npm_utils_1.getCliVersion)());
|
|
238
242
|
scope.setExtra("args", JSON.stringify(args));
|
|
239
243
|
scope.setExtra("host", auth.host);
|
|
240
244
|
});
|
|
241
245
|
}
|
|
242
246
|
/** PlasmicConfig **/
|
|
243
|
-
let configFile = args.config || config_utils_1.findConfigFile(args.baseDir, { traverseParents: true });
|
|
247
|
+
let configFile = args.config || (0, config_utils_1.findConfigFile)(args.baseDir, { traverseParents: true });
|
|
244
248
|
if (!configFile) {
|
|
245
249
|
yield maybeRunPlasmicInit(args, "plasmic.json", enableSkipAuth);
|
|
246
|
-
configFile = config_utils_1.findConfigFile(args.baseDir, { traverseParents: true });
|
|
250
|
+
configFile = (0, config_utils_1.findConfigFile)(args.baseDir, { traverseParents: true });
|
|
247
251
|
if (!configFile) {
|
|
248
252
|
const err = new error_1.HandledError("No plasmic.json file found. Please run `plasmic init` first.");
|
|
249
253
|
throw err;
|
|
@@ -252,8 +256,8 @@ function getContext(args, { enableSkipAuth = false } = {}) {
|
|
|
252
256
|
const rootDir = upath_1.default.dirname(configFile);
|
|
253
257
|
// plasmic.lock should be in the same directory as plasmic.json
|
|
254
258
|
const lockFile = upath_1.default.join(rootDir, config_utils_1.LOCK_FILE_NAME);
|
|
255
|
-
yield migrations_1.runNecessaryMigrations(configFile, lockFile, args.baseDir, args.yes);
|
|
256
|
-
const config = config_utils_1.readConfig(configFile, true);
|
|
259
|
+
yield (0, migrations_1.runNecessaryMigrations)(configFile, lockFile, args.baseDir, args.yes);
|
|
260
|
+
const config = (0, config_utils_1.readConfig)(configFile, true);
|
|
257
261
|
/** PlasmicLock */
|
|
258
262
|
const lock = readLock(lockFile);
|
|
259
263
|
const context = {
|
|
@@ -280,7 +284,7 @@ exports.getContext = getContext;
|
|
|
280
284
|
*/
|
|
281
285
|
function getCurrentOrDefaultAuth(args) {
|
|
282
286
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
const auth = yield auth_utils_1.getCurrentAuth(args.auth);
|
|
287
|
+
const auth = yield (0, auth_utils_1.getCurrentAuth)(args.auth);
|
|
284
288
|
if (auth) {
|
|
285
289
|
return auth;
|
|
286
290
|
}
|
|
@@ -293,12 +297,12 @@ function getCurrentOrDefaultAuth(args) {
|
|
|
293
297
|
}
|
|
294
298
|
function getOrInitAuth(args) {
|
|
295
299
|
return __awaiter(this, void 0, void 0, function* () {
|
|
296
|
-
const auth = yield auth_utils_1.getCurrentAuth(args.auth);
|
|
300
|
+
const auth = yield (0, auth_utils_1.getCurrentAuth)(args.auth);
|
|
297
301
|
if (auth) {
|
|
298
302
|
return auth;
|
|
299
303
|
}
|
|
300
304
|
if (yield maybeRunPlasmicInit(args, ".plasmic.auth")) {
|
|
301
|
-
return lang_utils_1.ensure(yield auth_utils_1.getCurrentAuth());
|
|
305
|
+
return (0, lang_utils_1.ensure)(yield (0, auth_utils_1.getCurrentAuth)());
|
|
302
306
|
}
|
|
303
307
|
// Could not find the authentication credentials and the user
|
|
304
308
|
// declined to run plasmic init.
|
|
@@ -310,7 +314,7 @@ function maybeRunPlasmicInit(args, missingFile, enableSkipAuth) {
|
|
|
310
314
|
if (!process.env.QUIET) {
|
|
311
315
|
deps_1.logger.info(`No ${missingFile} file found. Initializing plasmic...`);
|
|
312
316
|
}
|
|
313
|
-
yield init_1.initPlasmic(Object.assign({ host: config_utils_1.DEFAULT_HOST, platform: "", codeLang: "", codeScheme: "", styleScheme: "", imagesScheme: "", srcDir: "", plasmicDir: "", imagesPublicDir: "", imagesPublicUrlPrefix: "", enableSkipAuth }, args));
|
|
317
|
+
yield (0, init_1.initPlasmic)(Object.assign({ host: config_utils_1.DEFAULT_HOST, platform: "", codeLang: "", codeScheme: "", styleScheme: "", imagesScheme: "", srcDir: "", plasmicDir: "", imagesPublicDir: "", imagesPublicUrlPrefix: "", enableSkipAuth }, args));
|
|
314
318
|
return true;
|
|
315
319
|
});
|
|
316
320
|
}
|
package/dist/utils/help.js
CHANGED
|
@@ -10,12 +10,12 @@ const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
|
|
|
10
10
|
const deps_1 = require("../deps");
|
|
11
11
|
const lang_utils_1 = require("./lang-utils");
|
|
12
12
|
function wrap(str) {
|
|
13
|
-
return wrap_ansi_1.default(str, 60);
|
|
13
|
+
return (0, wrap_ansi_1.default)(str, 60);
|
|
14
14
|
}
|
|
15
15
|
function printFirstSyncInfo(context) {
|
|
16
16
|
const config = context.config;
|
|
17
17
|
if (config.code.scheme === "blackbox" && config.projects.length > 0) {
|
|
18
|
-
const project = lang_utils_1.ensure(lodash_1.default.last(config.projects));
|
|
18
|
+
const project = (0, lang_utils_1.ensure)(lodash_1.default.last(config.projects));
|
|
19
19
|
deps_1.logger.info(`\nYour Plasmic project "${project.projectName}" has now been synced to disk.`);
|
|
20
20
|
const exampleComponent = project.components[0];
|
|
21
21
|
if (exampleComponent) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type StringGen = string | (() => string);
|
|
2
2
|
export declare function flatMap<T, U>(arr: T[], f: (x: T) => U[]): U[];
|
|
3
3
|
export declare function ensure<T>(x: T | null | undefined, msg?: StringGen): T;
|
|
4
4
|
export declare function ensureString(x: any): string;
|
package/dist/utils/lang-utils.js
CHANGED
package/dist/utils/npm-utils.js
CHANGED
|
@@ -11,7 +11,7 @@ const semver_1 = __importDefault(require("semver"));
|
|
|
11
11
|
const deps_1 = require("../deps");
|
|
12
12
|
const file_utils_1 = require("./file-utils");
|
|
13
13
|
function getParsedCliPackageJson() {
|
|
14
|
-
const packageJson = findup_sync_1.default("package.json", { cwd: __dirname });
|
|
14
|
+
const packageJson = (0, findup_sync_1.default)("package.json", { cwd: __dirname });
|
|
15
15
|
if (!packageJson) {
|
|
16
16
|
throw new Error(`Cannot find package.json in ancestors of ${__dirname}`);
|
|
17
17
|
}
|
|
@@ -38,7 +38,7 @@ function checkEngineStrict() {
|
|
|
38
38
|
}
|
|
39
39
|
exports.checkEngineStrict = checkEngineStrict;
|
|
40
40
|
function getParsedPackageJson() {
|
|
41
|
-
const packageJson = findup_sync_1.default("package.json");
|
|
41
|
+
const packageJson = (0, findup_sync_1.default)("package.json");
|
|
42
42
|
if (!packageJson) {
|
|
43
43
|
throw new Error(`Cannot find package.json`);
|
|
44
44
|
}
|
|
@@ -50,37 +50,39 @@ function findInstalledVersion(config, baseDir, pkg) {
|
|
|
50
50
|
const pm = detectPackageManager(config, baseDir);
|
|
51
51
|
try {
|
|
52
52
|
if (pm === "yarn2") {
|
|
53
|
-
const output = child_process_1.execSync(`yarn info --json ${pkg}`).toString().trim();
|
|
53
|
+
const output = (0, child_process_1.execSync)(`yarn info --json ${pkg}`).toString().trim();
|
|
54
54
|
const info = JSON.parse(output);
|
|
55
55
|
return (_a = info === null || info === void 0 ? void 0 : info.children) === null || _a === void 0 ? void 0 : _a.Version;
|
|
56
56
|
}
|
|
57
57
|
else if (pm === "yarn") {
|
|
58
|
-
const output = child_process_1.execSync(`yarn list --json --pattern ${pkg}`)
|
|
58
|
+
const output = (0, child_process_1.execSync)(`yarn list --json --pattern ${pkg}`)
|
|
59
59
|
.toString()
|
|
60
60
|
.trim()
|
|
61
61
|
.split("\n");
|
|
62
62
|
for (const line of output) {
|
|
63
63
|
const info = JSON.parse(line);
|
|
64
|
-
if ((info === null || info === void 0 ? void 0 : info.type) === "tree" &&
|
|
64
|
+
if ((info === null || info === void 0 ? void 0 : info.type) === "tree" &&
|
|
65
|
+
((_e = (_d = (_c = (_b = info === null || info === void 0 ? void 0 : info.data) === null || _b === void 0 ? void 0 : _b.trees) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.startsWith(`${pkg}@`))) {
|
|
65
66
|
return info.data.trees[0].name.replace(`${pkg}@`, "");
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
else if (pm === "npm") {
|
|
70
|
-
const output = child_process_1.execSync(`npm list --package-lock-only --json ${pkg}`)
|
|
71
|
+
const output = (0, child_process_1.execSync)(`npm list --package-lock-only --json ${pkg}`)
|
|
71
72
|
.toString()
|
|
72
73
|
.trim();
|
|
73
74
|
const info = JSON.parse(output);
|
|
74
75
|
return (_g = (_f = info === null || info === void 0 ? void 0 : info.dependencies) === null || _f === void 0 ? void 0 : _f[pkg]) === null || _g === void 0 ? void 0 : _g.version;
|
|
75
76
|
}
|
|
76
77
|
else if (pm === "pnpm") {
|
|
77
|
-
const output = child_process_1.execSync(`pnpm list --json ${pkg}`).toString().trim();
|
|
78
|
+
const output = (0, child_process_1.execSync)(`pnpm list --json ${pkg}`).toString().trim();
|
|
78
79
|
const info = JSON.parse(output);
|
|
79
|
-
return ((_j = (_h = info === null || info === void 0 ? void 0 : info.dependencies) === null || _h === void 0 ? void 0 : _h[pkg]) === null || _j === void 0 ? void 0 : _j.version) ||
|
|
80
|
+
return ((_j = (_h = info === null || info === void 0 ? void 0 : info.dependencies) === null || _h === void 0 ? void 0 : _h[pkg]) === null || _j === void 0 ? void 0 : _j.version) ||
|
|
81
|
+
((_m = (_l = (_k = info === null || info === void 0 ? void 0 : info[0]) === null || _k === void 0 ? void 0 : _k.dependencies) === null || _l === void 0 ? void 0 : _l[pkg]) === null || _m === void 0 ? void 0 : _m.version);
|
|
80
82
|
}
|
|
81
83
|
else {
|
|
82
84
|
// Unknown package manager (e.g. pnpm).
|
|
83
|
-
const output = child_process_1.execSync(`npm list --json ${pkg}`).toString().trim();
|
|
85
|
+
const output = (0, child_process_1.execSync)(`npm list --json ${pkg}`).toString().trim();
|
|
84
86
|
const info = JSON.parse(output);
|
|
85
87
|
return (_p = (_o = info === null || info === void 0 ? void 0 : info.dependencies) === null || _o === void 0 ? void 0 : _o[pkg]) === null || _p === void 0 ? void 0 : _p.version;
|
|
86
88
|
}
|
|
@@ -109,7 +111,7 @@ function isCliGloballyInstalled(rootDir) {
|
|
|
109
111
|
}
|
|
110
112
|
exports.isCliGloballyInstalled = isCliGloballyInstalled;
|
|
111
113
|
function findPackageJsonPath(dir) {
|
|
112
|
-
return file_utils_1.findFile(dir, (f) => f === "package.json", {
|
|
114
|
+
return (0, file_utils_1.findFile)(dir, (f) => f === "package.json", {
|
|
113
115
|
traverseParents: true,
|
|
114
116
|
});
|
|
115
117
|
}
|
|
@@ -120,7 +122,7 @@ function findPackageJsonDir(rootDir) {
|
|
|
120
122
|
exports.findPackageJsonDir = findPackageJsonDir;
|
|
121
123
|
function parsePackageJson(path) {
|
|
122
124
|
try {
|
|
123
|
-
return JSON.parse(file_utils_1.readFileText(path));
|
|
125
|
+
return JSON.parse((0, file_utils_1.readFileText)(path));
|
|
124
126
|
}
|
|
125
127
|
catch (e) {
|
|
126
128
|
return undefined;
|
|
@@ -131,7 +133,7 @@ function installUpgrade(config, pkg, baseDir, opts = {}) {
|
|
|
131
133
|
if (!process.env.QUIET) {
|
|
132
134
|
deps_1.logger.info(cmd);
|
|
133
135
|
}
|
|
134
|
-
const r = child_process_1.spawnSync(cmd, {
|
|
136
|
+
const r = (0, child_process_1.spawnSync)(cmd, {
|
|
135
137
|
shell: true,
|
|
136
138
|
stdio: process.env.QUIET ? "ignore" : "inherit",
|
|
137
139
|
cwd: baseDir,
|
|
@@ -201,9 +203,9 @@ function detectPackageManager(config, baseDir) {
|
|
|
201
203
|
if (config.packageManager) {
|
|
202
204
|
return config.packageManager;
|
|
203
205
|
}
|
|
204
|
-
const yarnLock = findup_sync_1.default("yarn.lock", { cwd: baseDir });
|
|
206
|
+
const yarnLock = (0, findup_sync_1.default)("yarn.lock", { cwd: baseDir });
|
|
205
207
|
if (yarnLock) {
|
|
206
|
-
const yarnVersion = child_process_1.execSync(`yarn --version`).toString().trim();
|
|
208
|
+
const yarnVersion = (0, child_process_1.execSync)(`yarn --version`).toString().trim();
|
|
207
209
|
if (semver_1.default.gte(yarnVersion, "2.0.0")) {
|
|
208
210
|
return "yarn2";
|
|
209
211
|
}
|
|
@@ -211,11 +213,11 @@ function detectPackageManager(config, baseDir) {
|
|
|
211
213
|
return "yarn";
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
|
-
const pnpmLock = findup_sync_1.default("pnpm-lock.yaml", { cwd: baseDir });
|
|
216
|
+
const pnpmLock = (0, findup_sync_1.default)("pnpm-lock.yaml", { cwd: baseDir });
|
|
215
217
|
if (pnpmLock) {
|
|
216
218
|
return "pnpm";
|
|
217
219
|
}
|
|
218
|
-
const npmLock = findup_sync_1.default("package-lock.json", { cwd: baseDir });
|
|
220
|
+
const npmLock = (0, findup_sync_1.default)("package-lock.json", { cwd: baseDir });
|
|
219
221
|
if (npmLock) {
|
|
220
222
|
return "npm";
|
|
221
223
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -58,7 +62,7 @@ function walkDependencyTree(root, available) {
|
|
|
58
62
|
return Object.assign(Object.assign({}, meta), { indirect: meta.projectId !== root.projectId });
|
|
59
63
|
};
|
|
60
64
|
while (queue.length > 0) {
|
|
61
|
-
const curr = lang_utils_1.ensure(queue.shift());
|
|
65
|
+
const curr = (0, lang_utils_1.ensure)(queue.shift());
|
|
62
66
|
result.push(curr);
|
|
63
67
|
queue.push(...lodash_1.default.toPairs(curr.dependencies).map(([projectId, version]) => getMeta(projectId, version)));
|
|
64
68
|
}
|
|
@@ -137,7 +141,7 @@ function checkProjectMeta(meta, root, context, opts) {
|
|
|
137
141
|
}
|
|
138
142
|
else {
|
|
139
143
|
deps_1.logger.info(`'${root.projectName}' uses '${projectName}'@${newVersion}, but your code has version ${versionOnDisk}`);
|
|
140
|
-
return yield user_utils_1.confirmWithUser(`Do you want to upgrade '${projectName}' to ${newVersion}?`, opts.yes);
|
|
144
|
+
return yield (0, user_utils_1.confirmWithUser)(`Do you want to upgrade '${projectName}' to ${newVersion}?`, opts.yes);
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
throw new Error(`Error comparing version=${newVersion} with the version found in plasmic.lock (${versionOnDisk}) for '${projectName}'`);
|
|
@@ -162,14 +166,14 @@ function checkProjectMeta(meta, root, context, opts) {
|
|
|
162
166
|
return true;
|
|
163
167
|
}
|
|
164
168
|
deps_1.logger.warn(`${projectName}@${newVersion} falls outside the range specified in ${config_utils_1.CONFIG_FILE_NAME} (${versionRange})\nTip: To avoid this warning in the future, update your ${config_utils_1.CONFIG_FILE_NAME}.`);
|
|
165
|
-
return yield user_utils_1.confirmWithUser("Do you want to force it?", opts.force || opts.yes, "n");
|
|
169
|
+
return yield (0, user_utils_1.confirmWithUser)("Do you want to force it?", opts.force || opts.yes, "n");
|
|
166
170
|
});
|
|
167
171
|
const checkIndirect = () => __awaiter(this, void 0, void 0, function* () {
|
|
168
172
|
const projectConfig = context.config.projects.find((p) => p.projectId === projectId);
|
|
169
173
|
const configIndirect = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.indirect;
|
|
170
174
|
if (configIndirect && !indirect) {
|
|
171
175
|
deps_1.logger.warn(`'${projectName}' was synced indirectly before, but a direct sync was requested. If it has page components, they will be synced and saved to plasmic.json.`);
|
|
172
|
-
return yield user_utils_1.confirmWithUser("Do you want to confirm it?", opts.force || opts.yes, "n");
|
|
176
|
+
return yield (0, user_utils_1.confirmWithUser)("Do you want to confirm it?", opts.force || opts.yes, "n");
|
|
173
177
|
}
|
|
174
178
|
return true;
|
|
175
179
|
});
|
|
@@ -229,7 +233,7 @@ function checkVersionResolution(versionResolution, context, opts) {
|
|
|
229
233
|
else if (root.projectId === m.projectId) {
|
|
230
234
|
// If m is the root project and it was already seen (maybe as a dep
|
|
231
235
|
// for another project), set indirect = false.
|
|
232
|
-
const project = lang_utils_1.ensure(seen.find((p) => p.projectId === m.projectId));
|
|
236
|
+
const project = (0, lang_utils_1.ensure)(seen.find((p) => p.projectId === m.projectId));
|
|
233
237
|
project.indirect = false;
|
|
234
238
|
}
|
|
235
239
|
}
|
package/dist/utils/semver.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as semverlib from "semver";
|
|
|
5
5
|
* - "latest" range will match any valid version number
|
|
6
6
|
* - "latest" version will only match "latest" version range
|
|
7
7
|
**/
|
|
8
|
-
export
|
|
8
|
+
export type Version = semverlib.SemVer | "latest";
|
|
9
9
|
export declare const latestTag = "latest";
|
|
10
10
|
export declare const isLatest: (v: string) => boolean;
|
|
11
11
|
export declare const valid: (v: string) => string | null;
|
|
@@ -31,4 +31,4 @@ export declare const maxSatisfying: (versions: string[], range: string) => strin
|
|
|
31
31
|
export declare const coerce: (v: string) => string | undefined;
|
|
32
32
|
export declare const gtr: (version: string, range: string) => boolean;
|
|
33
33
|
export declare const ltr: (version: string, range: string) => boolean;
|
|
34
|
-
export declare const outside: (version: string, range: string, hilo?: ">" | "<"
|
|
34
|
+
export declare const outside: (version: string, range: string, hilo?: ">" | "<") => boolean;
|
package/dist/utils/semver.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -26,36 +30,61 @@ exports.outside = exports.ltr = exports.gtr = exports.coerce = exports.maxSatisf
|
|
|
26
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
27
31
|
const semverlib = __importStar(require("semver"));
|
|
28
32
|
exports.latestTag = "latest";
|
|
29
|
-
|
|
30
|
-
exports.
|
|
31
|
-
|
|
32
|
-
exports.
|
|
33
|
-
|
|
34
|
-
exports.
|
|
35
|
-
|
|
36
|
-
exports.
|
|
37
|
-
|
|
38
|
-
exports.
|
|
39
|
-
|
|
40
|
-
exports.
|
|
41
|
-
|
|
42
|
-
exports.
|
|
43
|
-
|
|
44
|
-
(!exports.isLatest(
|
|
45
|
-
exports.
|
|
46
|
-
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
|
|
53
|
-
exports.
|
|
54
|
-
|
|
55
|
-
exports.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
const isLatest = (v) => v === exports.latestTag;
|
|
34
|
+
exports.isLatest = isLatest;
|
|
35
|
+
const valid = (v) => (0, exports.isLatest)(v) ? exports.latestTag : semverlib.valid(v);
|
|
36
|
+
exports.valid = valid;
|
|
37
|
+
const inc = (v, release) => (0, exports.isLatest)(v) ? exports.latestTag : semverlib.inc(v, release);
|
|
38
|
+
exports.inc = inc;
|
|
39
|
+
const prerelease = (v) => (0, exports.isLatest)(v) ? [] : semverlib.prerelease(v);
|
|
40
|
+
exports.prerelease = prerelease;
|
|
41
|
+
const major = (v) => (0, exports.isLatest)(v) ? exports.latestTag : semverlib.major(v);
|
|
42
|
+
exports.major = major;
|
|
43
|
+
const minor = (v) => (0, exports.isLatest)(v) ? exports.latestTag : semverlib.minor(v);
|
|
44
|
+
exports.minor = minor;
|
|
45
|
+
const patch = (v) => (0, exports.isLatest)(v) ? exports.latestTag : semverlib.patch(v);
|
|
46
|
+
exports.patch = patch;
|
|
47
|
+
const eq = (v1, v2) => ((0, exports.isLatest)(v1) && (0, exports.isLatest)(v2)) ||
|
|
48
|
+
(!(0, exports.isLatest)(v1) && !(0, exports.isLatest)(v2) && semverlib.eq(v1, v2));
|
|
49
|
+
exports.eq = eq;
|
|
50
|
+
const gt = (v1, v2) => ((0, exports.isLatest)(v1) && !(0, exports.isLatest)(v2)) ||
|
|
51
|
+
(!(0, exports.isLatest)(v1) && !(0, exports.isLatest)(v2) && semverlib.gt(v1, v2));
|
|
52
|
+
exports.gt = gt;
|
|
53
|
+
const lt = (v1, v2) => (!(0, exports.isLatest)(v1) && (0, exports.isLatest)(v2)) ||
|
|
54
|
+
(!(0, exports.isLatest)(v1) && !(0, exports.isLatest)(v2) && semverlib.lt(v1, v2));
|
|
55
|
+
exports.lt = lt;
|
|
56
|
+
const validRange = (range) => (0, exports.isLatest)(range) ? exports.latestTag : semverlib.validRange(range);
|
|
57
|
+
exports.validRange = validRange;
|
|
58
|
+
const satisfies = (v, range) => ((0, exports.isLatest)(range) && !!(0, exports.valid)(v)) ||
|
|
59
|
+
(!(0, exports.isLatest)(v) && !(0, exports.isLatest)(range) && semverlib.satisfies(v, range));
|
|
60
|
+
exports.satisfies = satisfies;
|
|
61
|
+
const toTildeRange = (v) => (0, exports.isLatest)(v) ? exports.latestTag : !!semverlib.valid(v) ? "~" + v : null;
|
|
62
|
+
exports.toTildeRange = toTildeRange;
|
|
63
|
+
const toCaretRange = (v) => (0, exports.isLatest)(v) ? exports.latestTag : !!semverlib.valid(v) ? "^" + v : null;
|
|
64
|
+
exports.toCaretRange = toCaretRange;
|
|
65
|
+
const gte = (v1, v2) => (0, exports.eq)(v1, v2) || (0, exports.gt)(v1, v2);
|
|
66
|
+
exports.gte = gte;
|
|
67
|
+
const lte = (v1, v2) => (0, exports.eq)(v1, v2) || (0, exports.lt)(v1, v2);
|
|
68
|
+
exports.lte = lte;
|
|
69
|
+
const neq = (v1, v2) => !(0, exports.eq)(v1, v2);
|
|
70
|
+
exports.neq = neq;
|
|
71
|
+
const sortAsc = (versions) => lodash_1.default.cloneDeep(versions).sort((v1, v2) => (0, exports.gt)(v1, v2) ? +1 : (0, exports.eq)(v1, v2) ? 0 : -1);
|
|
72
|
+
exports.sortAsc = sortAsc;
|
|
73
|
+
const sortDesc = (versions) => (0, exports.sortAsc)(versions).reverse();
|
|
74
|
+
exports.sortDesc = sortDesc;
|
|
75
|
+
const minSatisfying = (versions, range) => { var _a; return (_a = (0, exports.sortAsc)(versions).find((v) => (0, exports.satisfies)(v, range))) !== null && _a !== void 0 ? _a : null; };
|
|
76
|
+
exports.minSatisfying = minSatisfying;
|
|
77
|
+
const maxSatisfying = (versions, range) => { var _a; return (_a = (0, exports.sortDesc)(versions).find((v) => (0, exports.satisfies)(v, range))) !== null && _a !== void 0 ? _a : null; };
|
|
78
|
+
exports.maxSatisfying = maxSatisfying;
|
|
79
|
+
const coerce = (v) => { var _a; return (0, exports.isLatest)(v) ? exports.latestTag : (_a = semverlib.coerce(v)) === null || _a === void 0 ? void 0 : _a.version; };
|
|
80
|
+
exports.coerce = coerce;
|
|
81
|
+
const gtr = (version, range) => ((0, exports.isLatest)(version) && !(0, exports.isLatest)(range)) ||
|
|
82
|
+
(!(0, exports.isLatest)(version) && !(0, exports.isLatest)(range) && semverlib.gtr(version, range));
|
|
83
|
+
exports.gtr = gtr;
|
|
84
|
+
const ltr = (version, range) => (!(0, exports.isLatest)(version) && (0, exports.isLatest)(range)) ||
|
|
85
|
+
(!(0, exports.isLatest)(version) && !(0, exports.isLatest)(range) && semverlib.ltr(version, range));
|
|
86
|
+
exports.ltr = ltr;
|
|
87
|
+
const outside = (version, range, hilo) => (hilo === ">" && (0, exports.gtr)(version, range)) ||
|
|
88
|
+
(hilo === "<" && (0, exports.ltr)(version, range)) ||
|
|
89
|
+
(!hilo && ((0, exports.gtr)(version, range) || (0, exports.ltr)(version, range)));
|
|
90
|
+
exports.outside = outside;
|
package/dist/utils/test-utils.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -40,16 +44,16 @@ class TempRepo {
|
|
|
40
44
|
}
|
|
41
45
|
readFile(relativePath) {
|
|
42
46
|
const absPath = this.resolveFile(relativePath);
|
|
43
|
-
const buf = file_utils_1.readFileText(absPath);
|
|
47
|
+
const buf = (0, file_utils_1.readFileText)(absPath);
|
|
44
48
|
return buf.toString();
|
|
45
49
|
}
|
|
46
50
|
writeFile(relativePath, data) {
|
|
47
51
|
const absPath = this.resolveFile(relativePath);
|
|
48
|
-
file_utils_1.writeFileText(absPath, data);
|
|
52
|
+
(0, file_utils_1.writeFileText)(absPath, data);
|
|
49
53
|
}
|
|
50
54
|
deleteFile(relativePath) {
|
|
51
55
|
const absPath = this.resolveFile(relativePath);
|
|
52
|
-
file_utils_1.deleteFileBuffered(absPath);
|
|
56
|
+
(0, file_utils_1.deleteFileBuffered)(absPath);
|
|
53
57
|
}
|
|
54
58
|
checkFile(relativePath) {
|
|
55
59
|
const absPath = this.resolveFile(relativePath);
|