@plasmicapp/cli 0.1.356 → 0.1.358

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 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,19 @@ function detectNextJsAppDir() {
487927
487927
  }
487928
487928
  return false;
487929
487929
  }
487930
+ function detectNextJsVersion() {
487931
+ var _a8;
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
+ return nextVersion;
487939
+ } catch {
487940
+ return void 0;
487941
+ }
487942
+ }
487930
487943
  function detectGatsby() {
487931
487944
  return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
487932
487945
  }
@@ -489211,6 +489224,7 @@ async function exportProjects(api, opts) {
489211
489224
  var _a9, _b2, _c3;
489212
489225
  return api.exportProject(v7.projectId, v7.branchName, {
489213
489226
  platform: (_a9 = opts.platform) != null ? _a9 : "react",
489227
+ platformVersion: opts.platformVersion,
489214
489228
  platformOptions: {},
489215
489229
  version: v7.version,
489216
489230
  imageOpts: (_b2 = opts.imageOpts) != null ? _b2 : {
@@ -490705,6 +490719,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
490705
490719
  branchName,
490706
490720
  {
490707
490721
  platform: context.config.platform,
490722
+ platformVersion: detectNextJsVersion(),
490708
490723
  platformOptions: context.config.platform === "nextjs" ? {
490709
490724
  nextjs: {
490710
490725
  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,19 @@ function detectNextJsAppDir() {
483232
483232
  }
483233
483233
  return false;
483234
483234
  }
483235
+ function detectNextJsVersion() {
483236
+ var _a8;
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
+ return nextVersion;
483244
+ } catch {
483245
+ return void 0;
483246
+ }
483247
+ }
483235
483248
  function detectGatsby() {
483236
483249
  return (0, import_findup_sync2.default)("gatsby-config.js") || (0, import_findup_sync2.default)("gatsby-config.ts");
483237
483250
  }
@@ -484506,6 +484519,7 @@ async function exportProjects(api, opts) {
484506
484519
  var _a9, _b2, _c3;
484507
484520
  return api.exportProject(v7.projectId, v7.branchName, {
484508
484521
  platform: (_a9 = opts.platform) != null ? _a9 : "react",
484522
+ platformVersion: opts.platformVersion,
484509
484523
  platformOptions: {},
484510
484524
  version: v7.version,
484511
484525
  imageOpts: (_b2 = opts.imageOpts) != null ? _b2 : {
@@ -486057,6 +486071,7 @@ async function syncProject(context, opts, projectIdsAndTokens, projectId, branch
486057
486071
  branchName,
486058
486072
  {
486059
486073
  platform: context.config.platform,
486074
+ platformVersion: detectNextJsVersion(),
486060
486075
  platformOptions: context.config.platform === "nextjs" ? {
486061
486076
  nextjs: {
486062
486077
  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.356",
3
+ "version": "0.1.358",
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": "8b07021bbf5b0f90eb8f8d1be179d74a34a4b19a"
85
+ "gitHead": "064aacd2bf8e30c06c81f2ed2be115df60134652"
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;
@@ -48,17 +48,6 @@ describe("detectNextJsAppDir", () => {
48
48
  expect(detectNextJsAppDir()).toBe(false);
49
49
  });
50
50
 
51
- it("returns false with pages router only", () => {
52
- fs.writeFileSync(
53
- path.join(tempDir, "next.config.js"),
54
- "module.exports = {};"
55
- );
56
- fs.mkdirSync(path.join(tempDir, "pages"));
57
- fs.writeFileSync(path.join(tempDir, "pages/index.tsx"), "");
58
-
59
- expect(detectNextJsAppDir()).toBe(false);
60
- });
61
-
62
51
  it("returns true with app router only", () => {
63
52
  fs.writeFileSync(
64
53
  path.join(tempDir, "next.config.js"),
@@ -113,3 +102,56 @@ describe("detectNextJsAppDir", () => {
113
102
  });
114
103
  });
115
104
  });
105
+
106
+ describe("detectNextJsVersion", () => {
107
+ let tempDir: string;
108
+ let originalCwd: string;
109
+
110
+ beforeEach(() => {
111
+ originalCwd = process.cwd();
112
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "envdetect-test-"));
113
+ console.log("Added temp dir at ", tempDir);
114
+ process.chdir(tempDir);
115
+ });
116
+
117
+ afterEach(() => {
118
+ process.chdir(originalCwd);
119
+ fs.rmSync(tempDir, { recursive: true, force: true });
120
+ });
121
+
122
+ function writePackageJson(deps: Record<string, string>) {
123
+ fs.writeFileSync(
124
+ path.join(tempDir, "package.json"),
125
+ JSON.stringify({ dependencies: deps })
126
+ );
127
+ }
128
+
129
+ it("returns undefined when no package.json exists", () => {
130
+ expect(detectNextJsVersion()).toBeUndefined();
131
+ });
132
+
133
+ it("returns undefined when next is not a dependency", () => {
134
+ writePackageJson({ react: "^18.0.0" });
135
+ expect(detectNextJsVersion()).toBeUndefined();
136
+ });
137
+
138
+ it("returns exact next version", () => {
139
+ writePackageJson({ next: "14.2.3" });
140
+ expect(detectNextJsVersion()).toBe("14.2.3");
141
+ });
142
+
143
+ it("returns caret range next version", () => {
144
+ writePackageJson({ next: "^13.4.0" });
145
+ expect(detectNextJsVersion()).toBe("^13.4.0");
146
+ });
147
+
148
+ it("returns tilde range next version", () => {
149
+ writePackageJson({ next: "~12.1.0" });
150
+ expect(detectNextJsVersion()).toBe("~12.1.0");
151
+ });
152
+
153
+ it("returns prerelease next version", () => {
154
+ writePackageJson({ next: "15.0.0-canary.1" });
155
+ expect(detectNextJsVersion()).toBe("15.0.0-canary.1");
156
+ });
157
+ });
@@ -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 ?? {
@@ -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;
@@ -71,6 +71,19 @@ 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
+ return nextVersion;
82
+ } catch {
83
+ return undefined;
84
+ }
85
+ }
86
+
74
87
  export function detectGatsby() {
75
88
  return findupSync("gatsby-config.js") || findupSync("gatsby-config.ts");
76
89
  }