create-plasmic-app 0.0.173 → 0.0.175
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const os_1 = __importDefault(require("os"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const vitest_1 = require("vitest");
|
|
19
|
+
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
20
|
+
const codegen_1 = require("../utils/codegen");
|
|
21
|
+
vitest_1.vi.mock("../utils/cmd-utils", () => ({
|
|
22
|
+
spawnOrFail: vitest_1.vi.fn().mockResolvedValue(undefined),
|
|
23
|
+
}));
|
|
24
|
+
(0, vitest_1.describe)("runCodegenSync", () => {
|
|
25
|
+
let projectPath;
|
|
26
|
+
(0, vitest_1.beforeEach)(() => {
|
|
27
|
+
projectPath = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "cpa-codegen-test-"));
|
|
28
|
+
fs_1.default.writeFileSync(path_1.default.join(projectPath, "plasmic.json"), "{}");
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.afterEach)(() => {
|
|
31
|
+
fs_1.default.rmSync(projectPath, { recursive: true, force: true });
|
|
32
|
+
vitest_1.vi.mocked(cmd_utils_1.spawnOrFail).mockClear();
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)("passes the package manager to the first Plasmic sync", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
yield (0, codegen_1.runCodegenSync)({
|
|
36
|
+
projectId: "project-id",
|
|
37
|
+
projectApiToken: undefined,
|
|
38
|
+
projectPath,
|
|
39
|
+
packageManager: "npm",
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.expect)(cmd_utils_1.spawnOrFail).toHaveBeenCalledWith("npx plasmic sync --yes --package-manager=npm -p project-id", projectPath);
|
|
42
|
+
(0, vitest_1.expect)(JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectPath, "plasmic.json"), "utf8"))).toMatchObject({ packageManager: "npm" });
|
|
43
|
+
}));
|
|
44
|
+
});
|
package/dist/utils/codegen.js
CHANGED
|
@@ -36,7 +36,9 @@ function runCodegenSync(opts) {
|
|
|
36
36
|
const project = projectApiToken
|
|
37
37
|
? `${projectId}:${projectApiToken}`
|
|
38
38
|
: projectId;
|
|
39
|
-
|
|
39
|
+
// Pin the manager during CLI initialization, before it installs required packages
|
|
40
|
+
// and could guess from an unrelated ancestor lockfile.
|
|
41
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${(0, npm_utils_1.packageManagerExec)(packageManager)} plasmic sync --yes --package-manager=${packageManager} -p ${project}`, projectPath);
|
|
40
42
|
// Pin the package manager, so syncs don't have to guess from lockfiles
|
|
41
43
|
const configPath = path_1.default.join(projectPath, "plasmic.json");
|
|
42
44
|
const config = JSON.parse(yield fs_1.promises.readFile(configPath, "utf8"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-plasmic-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.175",
|
|
4
4
|
"description": "Create Plasmic-powered React apps",
|
|
5
5
|
"homepage": "https://www.plasmic.app",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"update-notifier": "^5.1.0",
|
|
42
42
|
"validate-npm-package-name": "^3.0.0",
|
|
43
43
|
"yargs": "^16.2.2",
|
|
44
|
-
"@plasmicapp/cli": "0.1.
|
|
44
|
+
"@plasmicapp/cli": "0.1.377"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"test": "TEST_CWD=`pwd` pnpm -w test --passWithNoTests",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { spawnOrFail } from "../utils/cmd-utils";
|
|
6
|
+
import { runCodegenSync } from "../utils/codegen";
|
|
7
|
+
|
|
8
|
+
vi.mock("../utils/cmd-utils", () => ({
|
|
9
|
+
spawnOrFail: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
describe("runCodegenSync", () => {
|
|
13
|
+
let projectPath: string;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
projectPath = fs.mkdtempSync(path.join(os.tmpdir(), "cpa-codegen-test-"));
|
|
17
|
+
fs.writeFileSync(path.join(projectPath, "plasmic.json"), "{}");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
fs.rmSync(projectPath, { recursive: true, force: true });
|
|
22
|
+
vi.mocked(spawnOrFail).mockClear();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("passes the package manager to the first Plasmic sync", async () => {
|
|
26
|
+
await runCodegenSync({
|
|
27
|
+
projectId: "project-id",
|
|
28
|
+
projectApiToken: undefined,
|
|
29
|
+
projectPath,
|
|
30
|
+
packageManager: "npm",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(spawnOrFail).toHaveBeenCalledWith(
|
|
34
|
+
"npx plasmic sync --yes --package-manager=npm -p project-id",
|
|
35
|
+
projectPath
|
|
36
|
+
);
|
|
37
|
+
expect(
|
|
38
|
+
JSON.parse(
|
|
39
|
+
fs.readFileSync(path.join(projectPath, "plasmic.json"), "utf8")
|
|
40
|
+
)
|
|
41
|
+
).toMatchObject({ packageManager: "npm" });
|
|
42
|
+
});
|
|
43
|
+
});
|
package/src/utils/codegen.ts
CHANGED
|
@@ -31,8 +31,12 @@ export async function runCodegenSync(opts: {
|
|
|
31
31
|
? `${projectId}:${projectApiToken}`
|
|
32
32
|
: projectId;
|
|
33
33
|
|
|
34
|
+
// Pin the manager during CLI initialization, before it installs required packages
|
|
35
|
+
// and could guess from an unrelated ancestor lockfile.
|
|
34
36
|
await spawnOrFail(
|
|
35
|
-
`${packageManagerExec(
|
|
37
|
+
`${packageManagerExec(
|
|
38
|
+
packageManager
|
|
39
|
+
)} plasmic sync --yes --package-manager=${packageManager} -p ${project}`,
|
|
36
40
|
projectPath
|
|
37
41
|
);
|
|
38
42
|
|