@plasmicapp/cli 0.1.170 → 0.1.171
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/fix-imports.js +2 -2
- package/dist/actions/info.d.ts +5 -0
- package/dist/actions/info.js +27 -0
- package/dist/migrations/0.1.143-ensureImportModuleType.d.ts +2 -0
- package/dist/migrations/0.1.143-ensureImportModuleType.js +12 -0
- package/dist/utils/code-utils.js +2 -1
- package/dist/utils/file-utils.d.ts +0 -5
- package/dist/utils/file-utils.js +1 -32
- package/package.json +2 -2
- package/src/actions/fix-imports.ts +2 -3
- package/src/utils/code-utils.ts +1 -0
- package/src/utils/file-utils.ts +0 -41
|
@@ -11,14 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fixImports = void 0;
|
|
13
13
|
const code_utils_1 = require("../utils/code-utils");
|
|
14
|
-
const
|
|
14
|
+
const config_utils_1 = require("../utils/config-utils");
|
|
15
15
|
const get_context_1 = require("../utils/get-context");
|
|
16
16
|
function fixImports(opts) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
if (!opts.baseDir)
|
|
19
19
|
opts.baseDir = process.cwd();
|
|
20
20
|
const context = yield get_context_1.getContext(opts, { enableSkipAuth: true });
|
|
21
|
-
yield
|
|
21
|
+
yield config_utils_1.updateConfig(context, context.config, opts.baseDir);
|
|
22
22
|
yield code_utils_1.fixAllImportStatements(context, opts.baseDir);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.printProjectInfo = void 0;
|
|
13
|
+
const deps_1 = require("../deps");
|
|
14
|
+
const get_context_1 = require("../utils/get-context");
|
|
15
|
+
function printProjectInfo(opts) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
let context = yield get_context_1.getContext(opts);
|
|
18
|
+
const results = yield Promise.all(opts.projects.map((p) => __awaiter(this, void 0, void 0, function* () { return yield context.api.projectMeta(p); })));
|
|
19
|
+
for (const meta of results) {
|
|
20
|
+
deps_1.logger.info(`Id: ${meta.id}`);
|
|
21
|
+
deps_1.logger.info(`Name: ${meta.name}`);
|
|
22
|
+
deps_1.logger.info(`Host URL: ${meta.hostUrl}`);
|
|
23
|
+
deps_1.logger.info(`Last published version: ${meta.lastPublishedVersion}`);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.printProjectInfo = printProjectInfo;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureImportModuleType = void 0;
|
|
4
|
+
function ensureImportModuleType(config) {
|
|
5
|
+
for (const project of config.projects) {
|
|
6
|
+
for (const component of project.components) {
|
|
7
|
+
component.importSpec.moduleType = "local";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
12
|
+
exports.ensureImportModuleType = ensureImportModuleType;
|
package/dist/utils/code-utils.js
CHANGED
|
@@ -350,7 +350,8 @@ exports.fixAllImportStatements = fixAllImportStatements;
|
|
|
350
350
|
function fixComponentImportStatements(context, compConfig, fixImportContext, fixSkeletonModule, baseDir) {
|
|
351
351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
352
352
|
// If ComponentConfig.importPath is still a local file, we best-effort also fix up the import statements there.
|
|
353
|
-
if (
|
|
353
|
+
if (compConfig.type !== "mapped" &&
|
|
354
|
+
isLocalModulePath(compConfig.importSpec.modulePath) &&
|
|
354
355
|
fixSkeletonModule) {
|
|
355
356
|
yield fixFileImportStatements(context, compConfig.importSpec.modulePath, fixImportContext, true, baseDir);
|
|
356
357
|
}
|
|
@@ -45,11 +45,6 @@ export declare function findSrcDirPath(absoluteSrcDir: string, expectedPath: str
|
|
|
45
45
|
export declare function findFile(dir: string, pred: (name: string) => boolean, opts: {
|
|
46
46
|
traverseParents?: boolean;
|
|
47
47
|
}): string | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Fixes all src-relative file paths in PlasmicConfig by detecting file
|
|
50
|
-
* movement on disk.
|
|
51
|
-
*/
|
|
52
|
-
export declare function fixAllFilePaths(context: PlasmicContext, baseDir: string): Promise<void>;
|
|
53
48
|
/**
|
|
54
49
|
* Throws an error if some file in PlasmicConfig is not inside the root
|
|
55
50
|
* directory (i.e., the directory containing plasmic.json).
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.existsBuffered = exports.deleteFileBuffered = exports.renameFileBuffered = exports.readFileText = exports.writeFileText = exports.withBufferedFs = exports.assertAllPathsInRootDir = exports.
|
|
15
|
+
exports.existsBuffered = exports.deleteFileBuffered = exports.renameFileBuffered = exports.readFileText = exports.writeFileText = exports.withBufferedFs = exports.assertAllPathsInRootDir = exports.findFile = exports.findSrcDirPath = exports.buildBaseNameToFiles = exports.renameFile = exports.makeFilePath = exports.fileExists = exports.deleteFile = exports.readFileContent = exports.writeFileContent = exports.defaultPagePath = exports.defaultPublicResourcePath = exports.defaultResourcePath = exports.writeFileContentRaw = exports.stripExtension = void 0;
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const glob_1 = __importDefault(require("glob"));
|
|
18
18
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -219,37 +219,6 @@ function getAllPaths(context) {
|
|
|
219
219
|
}
|
|
220
220
|
return pairs;
|
|
221
221
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Fixes all src-relative file paths in PlasmicConfig by detecting file
|
|
224
|
-
* movement on disk.
|
|
225
|
-
*/
|
|
226
|
-
function fixAllFilePaths(context, baseDir) {
|
|
227
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
const baseNameToFiles = buildBaseNameToFiles(context);
|
|
229
|
-
let changed = false;
|
|
230
|
-
const paths = getAllPaths(context);
|
|
231
|
-
for (const { bundle, key } of paths) {
|
|
232
|
-
const known = bundle[key];
|
|
233
|
-
// Check null and undefined
|
|
234
|
-
if (known == null) {
|
|
235
|
-
throw new error_1.HandledError(`"${key} is required, but missing in ${config_utils_1.CONFIG_FILE_NAME}. Please restore the file or delete from ${config_utils_1.CONFIG_FILE_NAME} and run plasmic sync: ${bundle}"`);
|
|
236
|
-
}
|
|
237
|
-
// Check falsey values (e.g. "")
|
|
238
|
-
if (!known) {
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
const found = findSrcDirPath(context.absoluteSrcDir, known, baseNameToFiles);
|
|
242
|
-
if (known !== found) {
|
|
243
|
-
bundle[key] = found;
|
|
244
|
-
changed = true;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (changed) {
|
|
248
|
-
yield config_utils_1.updateConfig(context, context.config, baseDir);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
exports.fixAllFilePaths = fixAllFilePaths;
|
|
253
222
|
/**
|
|
254
223
|
* Throws an error if some file in PlasmicConfig is not inside the root
|
|
255
224
|
* directory (i.e., the directory containing plasmic.json).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.171",
|
|
4
4
|
"description": "plasmic cli for syncing local code with Plasmic designs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/preset-typescript": "^7.12.1",
|
|
23
|
-
"@plasmicapp/react-web": "^0.2.
|
|
23
|
+
"@plasmicapp/react-web": "^0.2.91",
|
|
24
24
|
"@types/findup-sync": "^2.0.2",
|
|
25
25
|
"@types/glob": "^7.1.3",
|
|
26
26
|
"@types/inquirer": "^6.5.0",
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { CommonArgs } from "..";
|
|
2
2
|
import { fixAllImportStatements } from "../utils/code-utils";
|
|
3
|
-
import {
|
|
3
|
+
import { updateConfig } from "../utils/config-utils";
|
|
4
4
|
import { getContext } from "../utils/get-context";
|
|
5
5
|
|
|
6
6
|
export interface FixImportsArgs extends CommonArgs {}
|
|
7
7
|
export async function fixImports(opts: FixImportsArgs) {
|
|
8
8
|
if (!opts.baseDir) opts.baseDir = process.cwd();
|
|
9
9
|
const context = await getContext(opts, { enableSkipAuth: true });
|
|
10
|
-
|
|
11
|
-
await fixAllFilePaths(context, opts.baseDir);
|
|
10
|
+
await updateConfig(context, context.config, opts.baseDir);
|
|
12
11
|
await fixAllImportStatements(context, opts.baseDir);
|
|
13
12
|
}
|
package/src/utils/code-utils.ts
CHANGED
|
@@ -487,6 +487,7 @@ async function fixComponentImportStatements(
|
|
|
487
487
|
) {
|
|
488
488
|
// If ComponentConfig.importPath is still a local file, we best-effort also fix up the import statements there.
|
|
489
489
|
if (
|
|
490
|
+
compConfig.type !== "mapped" &&
|
|
490
491
|
isLocalModulePath(compConfig.importSpec.modulePath) &&
|
|
491
492
|
fixSkeletonModule
|
|
492
493
|
) {
|
package/src/utils/file-utils.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
CONFIG_FILE_NAME,
|
|
12
12
|
PlasmicContext,
|
|
13
13
|
ProjectConfig,
|
|
14
|
-
updateConfig,
|
|
15
14
|
} from "./config-utils";
|
|
16
15
|
import { ensureString } from "./lang-utils";
|
|
17
16
|
import { confirmWithUser } from "./user-utils";
|
|
@@ -279,46 +278,6 @@ function getAllPaths(context: PlasmicContext): BundleKeyPair[] {
|
|
|
279
278
|
return pairs;
|
|
280
279
|
}
|
|
281
280
|
|
|
282
|
-
/**
|
|
283
|
-
* Fixes all src-relative file paths in PlasmicConfig by detecting file
|
|
284
|
-
* movement on disk.
|
|
285
|
-
*/
|
|
286
|
-
export async function fixAllFilePaths(
|
|
287
|
-
context: PlasmicContext,
|
|
288
|
-
baseDir: string
|
|
289
|
-
) {
|
|
290
|
-
const baseNameToFiles = buildBaseNameToFiles(context);
|
|
291
|
-
let changed = false;
|
|
292
|
-
|
|
293
|
-
const paths = getAllPaths(context);
|
|
294
|
-
for (const { bundle, key } of paths) {
|
|
295
|
-
const known = bundle[key];
|
|
296
|
-
// Check null and undefined
|
|
297
|
-
if (known == null) {
|
|
298
|
-
throw new HandledError(
|
|
299
|
-
`"${key} is required, but missing in ${CONFIG_FILE_NAME}. Please restore the file or delete from ${CONFIG_FILE_NAME} and run plasmic sync: ${bundle}"`
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
// Check falsey values (e.g. "")
|
|
303
|
-
if (!known) {
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
const found = findSrcDirPath(
|
|
307
|
-
context.absoluteSrcDir,
|
|
308
|
-
known,
|
|
309
|
-
baseNameToFiles
|
|
310
|
-
);
|
|
311
|
-
if (known !== found) {
|
|
312
|
-
bundle[key] = found;
|
|
313
|
-
changed = true;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (changed) {
|
|
318
|
-
await updateConfig(context, context.config, baseDir);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
281
|
/**
|
|
323
282
|
* Throws an error if some file in PlasmicConfig is not inside the root
|
|
324
283
|
* directory (i.e., the directory containing plasmic.json).
|