@plasmicapp/cli 0.1.356 → 0.1.357
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/api.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/lib.js +16 -0
- package/dist/utils/envdetect.d.ts +1 -0
- package/package.json +2 -2
- package/src/__tests__/envdetect.spec.ts +54 -1
- package/src/actions/export.ts +2 -0
- package/src/actions/sync.ts +2 -0
- package/src/api.ts +2 -0
- package/src/utils/envdetect.ts +14 -0
package/dist/api.d.ts
CHANGED
|
@@ -213,6 +213,7 @@ export declare class PlasmicApi {
|
|
|
213
213
|
*/
|
|
214
214
|
projectComponents(projectId: string, branchName: string, opts: {
|
|
215
215
|
platform: string;
|
|
216
|
+
platformVersion?: string;
|
|
216
217
|
platformOptions: {
|
|
217
218
|
nextjs?: {
|
|
218
219
|
appDir: boolean;
|
|
@@ -237,6 +238,7 @@ export declare class PlasmicApi {
|
|
|
237
238
|
*/
|
|
238
239
|
exportProject(projectId: string, branchName: string, opts: {
|
|
239
240
|
platform: string;
|
|
241
|
+
platformVersion?: string;
|
|
240
242
|
platformOptions: {
|
|
241
243
|
nextjs?: {
|
|
242
244
|
appDir: boolean;
|
package/dist/index.js
CHANGED
|
@@ -487927,6 +487927,20 @@ function detectNextJsAppDir() {
|
|
|
487927
487927
|
}
|
|
487928
487928
|
return false;
|
|
487929
487929
|
}
|
|
487930
|
+
function detectNextJsVersion() {
|
|
487931
|
+
var _a8, _b2;
|
|
487932
|
+
try {
|
|
487933
|
+
const packageJson = getParsedPackageJson();
|
|
487934
|
+
const nextVersion = (_a8 = packageJson.dependencies) == null ? void 0 : _a8.next;
|
|
487935
|
+
if (!nextVersion) {
|
|
487936
|
+
return void 0;
|
|
487937
|
+
}
|
|
487938
|
+
const major2 = (_b2 = import_semver2.default.coerce(nextVersion)) == null ? void 0 : _b2.major;
|
|
487939
|
+
return major2 != null ? String(major2) : void 0;
|
|
487940
|
+
} catch {
|
|
487941
|
+
return void 0;
|
|
487942
|
+
}
|
|
487943
|
+
}
|
|
487930
487944
|
function detectGatsby() {
|
|
487931
487945
|
return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
|
|
487932
487946
|
}
|
|
@@ -489211,6 +489225,7 @@ async function exportProjects(api, opts) {
|
|
|
489211
489225
|
var _a9, _b2, _c3;
|
|
489212
489226
|
return api.exportProject(v7.projectId, v7.branchName, {
|
|
489213
489227
|
platform: (_a9 = opts.platform) != null ? _a9 : "react",
|
|
489228
|
+
platformVersion: opts.platformVersion,
|
|
489214
489229
|
platformOptions: {},
|
|
489215
489230
|
version: v7.version,
|
|
489216
489231
|
imageOpts: (_b2 = opts.imageOpts) != null ? _b2 : {
|
|
@@ -490705,6 +490720,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
|
|
|
490705
490720
|
branchName,
|
|
490706
490721
|
{
|
|
490707
490722
|
platform: context.config.platform,
|
|
490723
|
+
platformVersion: detectNextJsVersion(),
|
|
490708
490724
|
platformOptions: context.config.platform === "nextjs" ? {
|
|
490709
490725
|
nextjs: {
|
|
490710
490726
|
appDir: ((_c3 = (_b2 = context.config.nextjsConfig) == null ? void 0 : _b2.pagesDir) == null ? void 0 : _c3.endsWith("app")) || false
|
package/dist/lib.js
CHANGED
|
@@ -483232,6 +483232,20 @@ function detectNextJsAppDir() {
|
|
|
483232
483232
|
}
|
|
483233
483233
|
return false;
|
|
483234
483234
|
}
|
|
483235
|
+
function detectNextJsVersion() {
|
|
483236
|
+
var _a8, _b2;
|
|
483237
|
+
try {
|
|
483238
|
+
const packageJson = getParsedPackageJson();
|
|
483239
|
+
const nextVersion = (_a8 = packageJson.dependencies) == null ? void 0 : _a8.next;
|
|
483240
|
+
if (!nextVersion) {
|
|
483241
|
+
return void 0;
|
|
483242
|
+
}
|
|
483243
|
+
const major2 = (_b2 = import_semver2.default.coerce(nextVersion)) == null ? void 0 : _b2.major;
|
|
483244
|
+
return major2 != null ? String(major2) : void 0;
|
|
483245
|
+
} catch {
|
|
483246
|
+
return void 0;
|
|
483247
|
+
}
|
|
483248
|
+
}
|
|
483235
483249
|
function detectGatsby() {
|
|
483236
483250
|
return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
|
|
483237
483251
|
}
|
|
@@ -484506,6 +484520,7 @@ async function exportProjects(api, opts) {
|
|
|
484506
484520
|
var _a9, _b2, _c3;
|
|
484507
484521
|
return api.exportProject(v7.projectId, v7.branchName, {
|
|
484508
484522
|
platform: (_a9 = opts.platform) != null ? _a9 : "react",
|
|
484523
|
+
platformVersion: opts.platformVersion,
|
|
484509
484524
|
platformOptions: {},
|
|
484510
484525
|
version: v7.version,
|
|
484511
484526
|
imageOpts: (_b2 = opts.imageOpts) != null ? _b2 : {
|
|
@@ -486057,6 +486072,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
|
|
|
486057
486072
|
branchName,
|
|
486058
486073
|
{
|
|
486059
486074
|
platform: context.config.platform,
|
|
486075
|
+
platformVersion: detectNextJsVersion(),
|
|
486060
486076
|
platformOptions: context.config.platform === "nextjs" ? {
|
|
486061
486077
|
nextjs: {
|
|
486062
486078
|
appDir: ((_c3 = (_b2 = context.config.nextjsConfig) == null ? void 0 : _b2.pagesDir) == null ? void 0 : _c3.endsWith("app")) || false
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function detectTypescript(): string | null;
|
|
2
2
|
export declare function detectNextJs(): boolean;
|
|
3
3
|
export declare function detectNextJsAppDir(): boolean;
|
|
4
|
+
export declare function detectNextJsVersion(): string | undefined;
|
|
4
5
|
export declare function detectGatsby(): string | null;
|
|
5
6
|
export declare function detectCreateReactApp(): boolean;
|
|
6
7
|
export declare function detectTanStackApp(): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.357",
|
|
4
4
|
"description": "plasmic cli for syncing local code with Plasmic designs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"wrap-ansi": "^7.0.0",
|
|
83
83
|
"yargs": "^15.4.1"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "fffe41a59e89c8286ddde32eff9655d435dff76a"
|
|
86
86
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import os from "os";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import { detectNextJsAppDir } from "../utils/envdetect";
|
|
6
|
+
import { detectNextJsAppDir, detectNextJsVersion } from "../utils/envdetect";
|
|
7
7
|
|
|
8
8
|
describe("detectNextJsAppDir", () => {
|
|
9
9
|
let tempDir: string;
|
|
@@ -113,3 +113,56 @@ describe("detectNextJsAppDir", () => {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
+
|
|
117
|
+
describe("detectNextJsVersion", () => {
|
|
118
|
+
let tempDir: string;
|
|
119
|
+
let originalCwd: string;
|
|
120
|
+
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
originalCwd = process.cwd();
|
|
123
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "envdetect-test-"));
|
|
124
|
+
console.log("Added temp dir at ", tempDir);
|
|
125
|
+
process.chdir(tempDir);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
afterEach(() => {
|
|
129
|
+
process.chdir(originalCwd);
|
|
130
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
function writePackageJson(deps: Record<string, string>) {
|
|
134
|
+
fs.writeFileSync(
|
|
135
|
+
path.join(tempDir, "package.json"),
|
|
136
|
+
JSON.stringify({ dependencies: deps })
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
it("returns undefined when no package.json exists", () => {
|
|
141
|
+
expect(detectNextJsVersion()).toBeUndefined();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("returns undefined when next is not a dependency", () => {
|
|
145
|
+
writePackageJson({ react: "^18.0.0" });
|
|
146
|
+
expect(detectNextJsVersion()).toBeUndefined();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("returns major version from exact version", () => {
|
|
150
|
+
writePackageJson({ next: "14.2.3" });
|
|
151
|
+
expect(detectNextJsVersion()).toBe("14");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("returns major version from caret range", () => {
|
|
155
|
+
writePackageJson({ next: "^13.4.0" });
|
|
156
|
+
expect(detectNextJsVersion()).toBe("13");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("returns major version from tilde range", () => {
|
|
160
|
+
writePackageJson({ next: "~12.1.0" });
|
|
161
|
+
expect(detectNextJsVersion()).toBe("12");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("returns major version from prerelease", () => {
|
|
165
|
+
writePackageJson({ next: "15.0.0-canary.1" });
|
|
166
|
+
expect(detectNextJsVersion()).toBe("15");
|
|
167
|
+
});
|
|
168
|
+
});
|
package/src/actions/export.ts
CHANGED
|
@@ -278,6 +278,7 @@ interface ExportOpts {
|
|
|
278
278
|
version?: string;
|
|
279
279
|
}[];
|
|
280
280
|
platform?: PlasmicConfig["platform"];
|
|
281
|
+
platformVersion?: string;
|
|
281
282
|
imageOpts?: ImagesConfig;
|
|
282
283
|
stylesOpts?: Omit<StyleConfig, "defaultStyleCssFilePath">;
|
|
283
284
|
i18nOpts?: I18NConfig;
|
|
@@ -313,6 +314,7 @@ async function exportProjects(api: PlasmicApi, opts: ExportOpts) {
|
|
|
313
314
|
versionsToSync.map(async (v) => {
|
|
314
315
|
return api.exportProject(v.projectId, v.branchName, {
|
|
315
316
|
platform: opts.platform ?? "react",
|
|
317
|
+
platformVersion: opts.platformVersion,
|
|
316
318
|
platformOptions: {},
|
|
317
319
|
version: v.version,
|
|
318
320
|
imageOpts: opts.imageOpts ?? {
|
package/src/actions/sync.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
getOrAddProjectLock,
|
|
30
30
|
updateConfig,
|
|
31
31
|
} from "../utils/config-utils";
|
|
32
|
+
import { detectNextJsVersion } from "../utils/envdetect";
|
|
32
33
|
import { HandledError } from "../utils/error";
|
|
33
34
|
import {
|
|
34
35
|
assertAllPathsInRootDir,
|
|
@@ -545,6 +546,7 @@ async function syncProject(
|
|
|
545
546
|
branchName,
|
|
546
547
|
{
|
|
547
548
|
platform: context.config.platform,
|
|
549
|
+
platformVersion: detectNextJsVersion(),
|
|
548
550
|
platformOptions:
|
|
549
551
|
context.config.platform === "nextjs"
|
|
550
552
|
? {
|
package/src/api.ts
CHANGED
|
@@ -314,6 +314,7 @@ export class PlasmicApi {
|
|
|
314
314
|
branchName: string,
|
|
315
315
|
opts: {
|
|
316
316
|
platform: string;
|
|
317
|
+
platformVersion?: string;
|
|
317
318
|
platformOptions: {
|
|
318
319
|
nextjs?: {
|
|
319
320
|
appDir: boolean;
|
|
@@ -350,6 +351,7 @@ export class PlasmicApi {
|
|
|
350
351
|
branchName: string,
|
|
351
352
|
opts: {
|
|
352
353
|
platform: string;
|
|
354
|
+
platformVersion?: string;
|
|
353
355
|
platformOptions: {
|
|
354
356
|
nextjs?: {
|
|
355
357
|
appDir: boolean;
|
package/src/utils/envdetect.ts
CHANGED
|
@@ -71,6 +71,20 @@ export function detectNextJsAppDir() {
|
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
export function detectNextJsVersion(): string | undefined {
|
|
75
|
+
try {
|
|
76
|
+
const packageJson = getParsedPackageJson();
|
|
77
|
+
const nextVersion: string | undefined = packageJson.dependencies?.next;
|
|
78
|
+
if (!nextVersion) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const major = semver.coerce(nextVersion)?.major;
|
|
82
|
+
return major != null ? String(major) : undefined;
|
|
83
|
+
} catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
74
88
|
export function detectGatsby() {
|
|
75
89
|
return findupSync("gatsby-config.js") || findupSync("gatsby-config.ts");
|
|
76
90
|
}
|