create-plasmic-app 0.0.105 → 0.0.107

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.
@@ -2,11 +2,17 @@ import js from '@eslint/js'
2
2
  import globals from 'globals'
3
3
  import reactHooks from 'eslint-plugin-react-hooks'
4
4
  import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import { defineConfig, globalIgnores } from 'eslint/config'
5
6
 
6
- export default [
7
- { ignores: ['dist'] },
7
+ export default defineConfig([
8
+ globalIgnores(['dist']),
8
9
  {
9
10
  files: ['**/*.{js,jsx}'],
11
+ extends: [
12
+ js.configs.recommended,
13
+ reactHooks.configs['recommended-latest'],
14
+ reactRefresh.configs.vite,
15
+ ],
10
16
  languageOptions: {
11
17
  ecmaVersion: 2020,
12
18
  globals: globals.browser,
@@ -16,18 +22,8 @@ export default [
16
22
  sourceType: 'module',
17
23
  },
18
24
  },
19
- plugins: {
20
- 'react-hooks': reactHooks,
21
- 'react-refresh': reactRefresh,
22
- },
23
25
  rules: {
24
- ...js.configs.recommended.rules,
25
- ...reactHooks.configs.recommended.rules,
26
26
  'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
27
- 'react-refresh/only-export-components': [
28
- 'warn',
29
- { allowConstantExport: true },
30
- ],
31
27
  },
32
28
  },
33
- ]
29
+ ])
@@ -10,20 +10,20 @@
10
10
  "preview": "vite preview"
11
11
  },
12
12
  "dependencies": {
13
- "@plasmicapp/cli": "^0.1.337",
14
- "@plasmicapp/react-web": "^0.2.381",
15
- "react": "^19.0.0",
16
- "react-dom": "^19.0.0"
13
+ "@plasmicapp/cli": "^0.1.338",
14
+ "@plasmicapp/react-web": "^0.2.393",
15
+ "react": "^19.1.0",
16
+ "react-dom": "^19.1.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@eslint/js": "^9.22.0",
20
- "@types/react": "^19.0.10",
21
- "@types/react-dom": "^19.0.4",
22
- "@vitejs/plugin-react": "^4.3.4",
23
- "eslint": "^9.22.0",
19
+ "@eslint/js": "^9.29.0",
20
+ "@types/react": "^19.1.8",
21
+ "@types/react-dom": "^19.1.6",
22
+ "@vitejs/plugin-react": "^4.5.2",
23
+ "eslint": "^9.29.0",
24
24
  "eslint-plugin-react-hooks": "^5.2.0",
25
- "eslint-plugin-react-refresh": "^0.4.19",
26
- "globals": "^16.0.0",
27
- "vite": "^6.3.1"
25
+ "eslint-plugin-react-refresh": "^0.4.20",
26
+ "globals": "^16.2.0",
27
+ "vite": "^7.0.0"
28
28
  }
29
29
  }
@@ -128,6 +128,6 @@
128
128
  ]
129
129
  },
130
130
  "wrapPagesWithGlobalContexts": true,
131
- "cliVersion": "0.1.337",
132
- "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.337/dist/plasmic.schema.json"
131
+ "cliVersion": "0.1.338",
132
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.338/dist/plasmic.schema.json"
133
133
  }
@@ -9,6 +9,14 @@ export const ScreenContext = React.createContext(
9
9
  "PLEASE_RENDER_INSIDE_PROVIDER"
10
10
  );
11
11
 
12
+ export function ScreenContextProvider(props) {
13
+ return (
14
+ <ScreenContext.Provider value={props.value}>
15
+ {props.children}
16
+ </ScreenContext.Provider>
17
+ );
18
+ }
19
+
12
20
  export const useScreenVariants = createUseScreenVariants(true, {
13
21
  desktopOnly: "(min-width:768px)",
14
22
  });
@@ -3,26 +3,21 @@ import globals from 'globals'
3
3
  import reactHooks from 'eslint-plugin-react-hooks'
4
4
  import reactRefresh from 'eslint-plugin-react-refresh'
5
5
  import tseslint from 'typescript-eslint'
6
+ import { globalIgnores } from 'eslint/config'
6
7
 
7
- export default tseslint.config(
8
- { ignores: ['dist'] },
8
+ export default tseslint.config([
9
+ globalIgnores(['dist']),
9
10
  {
10
- extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
11
  files: ['**/*.{ts,tsx}'],
12
+ extends: [
13
+ js.configs.recommended,
14
+ tseslint.configs.recommended,
15
+ reactHooks.configs['recommended-latest'],
16
+ reactRefresh.configs.vite,
17
+ ],
12
18
  languageOptions: {
13
19
  ecmaVersion: 2020,
14
20
  globals: globals.browser,
15
21
  },
16
- plugins: {
17
- 'react-hooks': reactHooks,
18
- 'react-refresh': reactRefresh,
19
- },
20
- rules: {
21
- ...reactHooks.configs.recommended.rules,
22
- 'react-refresh/only-export-components': [
23
- 'warn',
24
- { allowConstantExport: true },
25
- ],
26
- },
27
22
  },
28
- )
23
+ ])
@@ -10,22 +10,22 @@
10
10
  "preview": "vite preview"
11
11
  },
12
12
  "dependencies": {
13
- "@plasmicapp/cli": "^0.1.337",
14
- "@plasmicapp/react-web": "^0.2.381",
15
- "react": "^19.0.0",
16
- "react-dom": "^19.0.0"
13
+ "@plasmicapp/cli": "^0.1.338",
14
+ "@plasmicapp/react-web": "^0.2.393",
15
+ "react": "^19.1.0",
16
+ "react-dom": "^19.1.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@eslint/js": "^9.22.0",
20
- "@types/react": "^19.0.10",
21
- "@types/react-dom": "^19.0.4",
22
- "@vitejs/plugin-react": "^4.3.4",
23
- "eslint": "^9.22.0",
19
+ "@eslint/js": "^9.29.0",
20
+ "@types/react": "^19.1.8",
21
+ "@types/react-dom": "^19.1.6",
22
+ "@vitejs/plugin-react": "^4.5.2",
23
+ "eslint": "^9.29.0",
24
24
  "eslint-plugin-react-hooks": "^5.2.0",
25
- "eslint-plugin-react-refresh": "^0.4.19",
26
- "globals": "^16.0.0",
27
- "typescript": "~5.7.2",
28
- "typescript-eslint": "^8.26.1",
29
- "vite": "^6.3.1"
25
+ "eslint-plugin-react-refresh": "^0.4.20",
26
+ "globals": "^16.2.0",
27
+ "typescript": "~5.8.3",
28
+ "typescript-eslint": "^8.34.1",
29
+ "vite": "^7.0.0"
30
30
  }
31
31
  }
@@ -128,6 +128,6 @@
128
128
  ]
129
129
  },
130
130
  "wrapPagesWithGlobalContexts": true,
131
- "cliVersion": "0.1.337",
132
- "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.337/dist/plasmic.schema.json"
131
+ "cliVersion": "0.1.338",
132
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.338/dist/plasmic.schema.json"
133
133
  }
@@ -10,6 +10,15 @@ export type ScreenValue = "desktopOnly";
10
10
  export const ScreenContext = React.createContext<ScreenValue[] | undefined>(
11
11
  "PLEASE_RENDER_INSIDE_PROVIDER" as any
12
12
  );
13
+ export function ScreenContextProvider(
14
+ props: React.PropsWithChildren<{ value: ScreenValue[] | undefined }>
15
+ ) {
16
+ return (
17
+ <ScreenContext.Provider value={props.value}>
18
+ {props.children}
19
+ </ScreenContext.Provider>
20
+ );
21
+ }
13
22
 
14
23
  export const useScreenVariants = createUseScreenVariants(true, {
15
24
  desktopOnly: "(min-width:768px)",
@@ -10,7 +10,7 @@
10
10
  /* Bundler mode */
11
11
  "moduleResolution": "bundler",
12
12
  "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
13
+ "verbatimModuleSyntax": false,
14
14
  "noEmit": true,
15
15
 
16
16
  /* Linting */
package/dist/index.js CHANGED
@@ -151,25 +151,6 @@ function run() {
151
151
  });
152
152
  // Absolute path to the new project
153
153
  resolvedProjectPath = path.resolve(projectName);
154
- // Prompt for Typescript
155
- const jsOrTs = (yield maybePrompt({
156
- name: "typescript",
157
- message: "What language do you want to use?",
158
- type: "list",
159
- choices: () => [
160
- {
161
- name: "TypeScript",
162
- value: true,
163
- },
164
- {
165
- name: "JavaScript",
166
- value: false,
167
- },
168
- ],
169
- default: true,
170
- }))
171
- ? "ts"
172
- : "js";
173
154
  // Prompt for the platform
174
155
  const platform = yield maybePrompt({
175
156
  name: "platform",
@@ -198,6 +179,25 @@ function run() {
198
179
  ],
199
180
  default: "nextjs",
200
181
  });
182
+ // Prompt for Typescript
183
+ const jsOrTs = platform === "tanstack"
184
+ ? "ts"
185
+ : yield maybePrompt({
186
+ name: "typescript",
187
+ message: "What language do you want to use?",
188
+ type: "list",
189
+ choices: () => [
190
+ {
191
+ name: "TypeScript",
192
+ value: "ts",
193
+ },
194
+ {
195
+ name: "JavaScript",
196
+ value: "js",
197
+ },
198
+ ],
199
+ default: "ts",
200
+ });
201
201
  // Scheme to use for Plasmic integration
202
202
  // - loader only available for gatsby/next.js
203
203
  const scheme = platform === "nextjs" || platform === "gatsby"
@@ -50,13 +50,15 @@ exports.tanstackStrategy = {
50
50
  }
51
51
  }),
52
52
  overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
53
- const { projectPath, jsOrTs } = args;
53
+ const { projectPath } = args;
54
54
  /* We need to provide @plasmicapp/* packages in noExternal ssr packages for
55
55
  * them to work properly during ssr phase.
56
56
  */
57
- if (jsOrTs === "ts") {
58
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "vite.config.ts"), (0, config_1.makeCustomViteConfig_file_router_codegen)());
59
- }
57
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "vite.config.ts"), (0, config_1.makeCustomViteConfig_file_router_codegen)());
58
+ // Disable verbatimModuleSyntax in tsconfig.json
59
+ const tsconfigPath = path_1.default.join(projectPath, "tsconfig.json");
60
+ const tsconfigContent = yield fs_1.promises.readFile(tsconfigPath, "utf8");
61
+ yield fs_1.promises.writeFile(tsconfigPath, tsconfigContent.replace(`"verbatimModuleSyntax": true`, `"verbatimModuleSyntax": false`));
60
62
  }),
61
63
  generateFiles: (args) => {
62
64
  return generateFilesFileRouterTemplate(args);
@@ -68,7 +70,7 @@ exports.tanstackStrategy = {
68
70
  };
69
71
  function generateFilesFileRouterTemplate(args) {
70
72
  return __awaiter(this, void 0, void 0, function* () {
71
- const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
73
+ const { projectPath, scheme, projectId, projectApiToken } = args;
72
74
  // Delete existing pages
73
75
  (0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/routes", "*.*"));
74
76
  if (scheme === "loader") {
@@ -76,9 +78,9 @@ function generateFilesFileRouterTemplate(args) {
76
78
  }
77
79
  else {
78
80
  // ./src/routes/__root.tsx
79
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", `__root.${jsOrTs}x`), (0, root_1.makeCustomRoot_file_router_codegen)(jsOrTs));
81
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", "__root.tsx"), (0, root_1.makeCustomRoot_file_router_codegen)());
80
82
  // ./src/routes/plasmic-host.tsx
81
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_1.makePlasmicHostPage_fileRouter_codegen)());
83
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", "plasmic-host.tsx"), (0, plasmic_host_1.makePlasmicHostPage_fileRouter_codegen)());
82
84
  // This should generate
83
85
  // ./plasmic.json
84
86
  // ./routes/index.tsx
@@ -1,2 +1 @@
1
- import { JsOrTs } from "../../../utils/types";
2
- export declare function makeCustomRoot_file_router_codegen(_jsOrTs: JsOrTs): string;
1
+ export declare function makeCustomRoot_file_router_codegen(): string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeCustomRoot_file_router_codegen = void 0;
4
- function makeCustomRoot_file_router_codegen(_jsOrTs) {
4
+ function makeCustomRoot_file_router_codegen() {
5
5
  return `import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router'
6
6
  import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
7
7
  import { PlasmicRootProvider } from "@plasmicapp/react-web"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-plasmic-app",
3
- "version": "0.0.105",
3
+ "version": "0.0.107",
4
4
  "description": "Create Plasmic-powered React apps",
5
5
  "main": "./dist/lib.js",
6
6
  "types": "./dist/lib.d.ts",
@@ -46,5 +46,5 @@
46
46
  "validate-npm-package-name": "^3.0.0",
47
47
  "yargs": "^16.2.0"
48
48
  },
49
- "gitHead": "0c49eb5026b12b17d836be44234696d1f7560140"
49
+ "gitHead": "7eba0fb9492e4b1907a42537163ba9d1e91f8482"
50
50
  }
package/run-cpa.ts CHANGED
@@ -31,11 +31,13 @@ async function run() {
31
31
  typescript,
32
32
  });
33
33
  if (scheme === "codegen") {
34
- allArgSets.push({
35
- platform: "tanstack",
36
- scheme,
37
- typescript,
38
- });
34
+ if (typescript) {
35
+ allArgSets.push({
36
+ platform: "tanstack",
37
+ scheme,
38
+ typescript,
39
+ });
40
+ }
39
41
 
40
42
  allArgSets.push({
41
43
  platform: "react",
package/src/index.ts CHANGED
@@ -8,7 +8,12 @@ import yargs from "yargs";
8
8
  import * as cpa from "./lib";
9
9
  import { ensure } from "./utils/lang-utils";
10
10
  import { checkEngineStrict, updateNotify } from "./utils/npm-utils";
11
- import { PlatformOptions, PlatformType, SchemeType } from "./utils/types";
11
+ import {
12
+ JsOrTs,
13
+ PlatformOptions,
14
+ PlatformType,
15
+ SchemeType,
16
+ } from "./utils/types";
12
17
 
13
18
  if (process.env.CPA_DEBUG_CHDIR) {
14
19
  process.chdir(process.env.CPA_DEBUG_CHDIR);
@@ -138,26 +143,6 @@ async function run(): Promise<void> {
138
143
  // Absolute path to the new project
139
144
  resolvedProjectPath = path.resolve(projectName);
140
145
 
141
- // Prompt for Typescript
142
- const jsOrTs = (await maybePrompt({
143
- name: "typescript",
144
- message: "What language do you want to use?",
145
- type: "list",
146
- choices: () => [
147
- {
148
- name: "TypeScript",
149
- value: true,
150
- },
151
- {
152
- name: "JavaScript",
153
- value: false,
154
- },
155
- ],
156
- default: true,
157
- }))
158
- ? "ts"
159
- : "js";
160
-
161
146
  // Prompt for the platform
162
147
  const platform = await maybePrompt<PlatformType>({
163
148
  name: "platform",
@@ -187,6 +172,27 @@ async function run(): Promise<void> {
187
172
  default: "nextjs",
188
173
  });
189
174
 
175
+ // Prompt for Typescript
176
+ const jsOrTs: JsOrTs =
177
+ platform === "tanstack"
178
+ ? "ts"
179
+ : await maybePrompt({
180
+ name: "typescript",
181
+ message: "What language do you want to use?",
182
+ type: "list",
183
+ choices: () => [
184
+ {
185
+ name: "TypeScript",
186
+ value: "ts",
187
+ },
188
+ {
189
+ name: "JavaScript",
190
+ value: "js",
191
+ },
192
+ ],
193
+ default: "ts",
194
+ });
195
+
190
196
  // Scheme to use for Plasmic integration
191
197
  // - loader only available for gatsby/next.js
192
198
  const scheme: SchemeType =
@@ -43,17 +43,26 @@ export const tanstackStrategy: CPAStrategy = {
43
43
  }
44
44
  },
45
45
  overwriteConfig: async (args) => {
46
- const { projectPath, jsOrTs } = args;
46
+ const { projectPath } = args;
47
47
 
48
48
  /* We need to provide @plasmicapp/* packages in noExternal ssr packages for
49
49
  * them to work properly during ssr phase.
50
50
  */
51
- if (jsOrTs === "ts") {
52
- await fs.writeFile(
53
- path.join(projectPath, "vite.config.ts"),
54
- makeCustomViteConfig_file_router_codegen()
55
- );
56
- }
51
+ await fs.writeFile(
52
+ path.join(projectPath, "vite.config.ts"),
53
+ makeCustomViteConfig_file_router_codegen()
54
+ );
55
+
56
+ // Disable verbatimModuleSyntax in tsconfig.json
57
+ const tsconfigPath = path.join(projectPath, "tsconfig.json");
58
+ const tsconfigContent = await fs.readFile(tsconfigPath, "utf8");
59
+ await fs.writeFile(
60
+ tsconfigPath,
61
+ tsconfigContent.replace(
62
+ `"verbatimModuleSyntax": true`,
63
+ `"verbatimModuleSyntax": false`
64
+ )
65
+ );
57
66
  },
58
67
  generateFiles: (args) => {
59
68
  return generateFilesFileRouterTemplate(args);
@@ -65,7 +74,7 @@ export const tanstackStrategy: CPAStrategy = {
65
74
  };
66
75
 
67
76
  async function generateFilesFileRouterTemplate(args: GenerateFilesArgs) {
68
- const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
77
+ const { projectPath, scheme, projectId, projectApiToken } = args;
69
78
 
70
79
  // Delete existing pages
71
80
  deleteGlob(path.join(projectPath, "src/routes", "*.*"));
@@ -77,13 +86,13 @@ async function generateFilesFileRouterTemplate(args: GenerateFilesArgs) {
77
86
  } else {
78
87
  // ./src/routes/__root.tsx
79
88
  await fs.writeFile(
80
- path.join(projectPath, "src/routes", `__root.${jsOrTs}x`),
81
- makeCustomRoot_file_router_codegen(jsOrTs)
89
+ path.join(projectPath, "src/routes", "__root.tsx"),
90
+ makeCustomRoot_file_router_codegen()
82
91
  );
83
92
 
84
93
  // ./src/routes/plasmic-host.tsx
85
94
  await fs.writeFile(
86
- path.join(projectPath, "src/routes", `plasmic-host.${jsOrTs}x`),
95
+ path.join(projectPath, "src/routes", "plasmic-host.tsx"),
87
96
  makePlasmicHostPage_fileRouter_codegen()
88
97
  );
89
98
 
@@ -1,6 +1,4 @@
1
- import { JsOrTs } from "../../../utils/types";
2
-
3
- export function makeCustomRoot_file_router_codegen(_jsOrTs: JsOrTs): string {
1
+ export function makeCustomRoot_file_router_codegen(): string {
4
2
  return `import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router'
5
3
  import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
6
4
  import { PlasmicRootProvider } from "@plasmicapp/react-web"