@tanstack/create 0.68.1 → 0.68.3
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/CHANGELOG.md +12 -0
- package/dist/create-app.js +22 -0
- package/dist/edge-add-ons.js +106 -0
- package/dist/edge-config-file.js +15 -0
- package/dist/edge-create-app.js +438 -0
- package/dist/edge-environment.js +141 -0
- package/dist/edge-file-helpers.js +88 -0
- package/dist/edge-frameworks.js +33 -0
- package/dist/edge-package-json.js +146 -0
- package/dist/edge-path.js +62 -0
- package/dist/edge-render.js +31 -0
- package/dist/edge-template-file.js +141 -0
- package/dist/edge.js +7 -0
- package/dist/frameworks/react/add-ons/storybook/info.json +5 -10
- package/dist/frameworks/react/project/base/_dot_gitignore +0 -1
- package/dist/frameworks/react/project/base/package.json +1 -0
- package/dist/frameworks/react/project/base/tsr.config.json +3 -0
- package/dist/frameworks/react/project/packages.json +3 -0
- package/dist/frameworks/solid/project/base/_dot_gitignore +0 -1
- package/dist/frameworks/solid/project/base/package.json +1 -0
- package/dist/frameworks/solid/project/base/tsr.config.json +3 -0
- package/dist/frameworks/solid/project/packages.json +3 -0
- package/dist/generated/create-manifest.js +4683 -0
- package/dist/manifest-types.js +1 -0
- package/dist/manifest.js +1 -0
- package/dist/types/custom-add-ons/add-on.d.ts +5 -3
- package/dist/types/edge-add-ons.d.ts +5 -0
- package/dist/types/edge-config-file.d.ts +8 -0
- package/dist/types/edge-create-app.d.ts +2 -0
- package/dist/types/edge-environment.d.ts +19 -0
- package/dist/types/edge-file-helpers.d.ts +7 -0
- package/dist/types/edge-frameworks.d.ts +7 -0
- package/dist/types/edge-package-json.d.ts +3 -0
- package/dist/types/edge-path.d.ts +5 -0
- package/dist/types/edge-render.d.ts +1 -0
- package/dist/types/edge-template-file.d.ts +2 -0
- package/dist/types/edge.d.ts +9 -0
- package/dist/types/generated/create-manifest.d.ts +36 -0
- package/dist/types/manifest-types.d.ts +4 -0
- package/dist/types/manifest.d.ts +1 -0
- package/dist/types/types.d.ts +96 -56
- package/dist/types.js +5 -3
- package/package.json +25 -5
- package/scripts/generate-manifest.mjs +407 -0
- package/src/create-app.ts +32 -1
- package/src/edge-add-ons.ts +138 -0
- package/src/edge-config-file.ts +35 -0
- package/src/edge-create-app.ts +594 -0
- package/src/edge-environment.ts +175 -0
- package/src/edge-file-helpers.ts +112 -0
- package/src/edge-frameworks.ts +54 -0
- package/src/edge-package-json.ts +212 -0
- package/src/edge-path.ts +77 -0
- package/src/edge-render.ts +32 -0
- package/src/edge-template-file.ts +204 -0
- package/src/edge.ts +43 -0
- package/src/frameworks/react/add-ons/storybook/info.json +5 -10
- package/src/frameworks/react/project/base/_dot_gitignore +0 -1
- package/src/frameworks/react/project/base/package.json +1 -0
- package/src/frameworks/react/project/base/tsr.config.json +3 -0
- package/src/frameworks/react/project/packages.json +3 -0
- package/src/frameworks/solid/project/base/_dot_gitignore +0 -1
- package/src/frameworks/solid/project/base/package.json +1 -0
- package/src/frameworks/solid/project/base/tsr.config.json +3 -0
- package/src/frameworks/solid/project/packages.json +3 -0
- package/src/generated/create-manifest.ts +6490 -0
- package/src/manifest-types.ts +8 -0
- package/src/manifest.ts +1 -0
- package/src/types.ts +5 -3
- package/tests/create-app.test.ts +39 -3
- package/tests/edge-import.test.ts +31 -0
- package/tests/edge-manifest.test.ts +168 -0
- package/tests/framework-template.test.ts +21 -2
- package/dist/frameworks/react/add-ons/storybook/assets/_dot_storybook/main.ts +0 -17
- package/dist/frameworks/react/add-ons/storybook/assets/_dot_storybook/preview.ts +0 -15
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.stories.ts +0 -67
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.tsx +0 -47
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.stories.tsx +0 -92
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.tsx +0 -29
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/index.ts +0 -14
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.stories.ts +0 -43
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.tsx +0 -39
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.stories.ts +0 -53
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.tsx +0 -52
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.stories.ts +0 -55
- package/dist/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.tsx +0 -57
- package/dist/frameworks/react/add-ons/storybook/assets/src/routes/demo/storybook.tsx +0 -93
- package/dist/frameworks/react/add-ons/storybook/package.json +0 -10
- package/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/main.ts +0 -17
- package/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/preview.ts +0 -15
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.stories.ts +0 -67
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.tsx +0 -47
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.stories.tsx +0 -92
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.tsx +0 -29
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/index.ts +0 -14
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.stories.ts +0 -43
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.tsx +0 -39
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.stories.ts +0 -53
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.tsx +0 -52
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.stories.ts +0 -55
- package/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.tsx +0 -57
- package/src/frameworks/react/add-ons/storybook/assets/src/routes/demo/storybook.tsx +0 -93
- package/src/frameworks/react/add-ons/storybook/package.json +0 -10
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { render } from './edge-render.js'
|
|
2
|
+
import { relativePath } from './edge-file-helpers.js'
|
|
3
|
+
import { joinPaths } from './edge-path.js'
|
|
4
|
+
import { formatCommand } from './utils.js'
|
|
5
|
+
import {
|
|
6
|
+
getPackageManagerExecuteCommand,
|
|
7
|
+
getPackageManagerInstallCommand,
|
|
8
|
+
getPackageManagerScriptCommand,
|
|
9
|
+
} from './package-manager.js'
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
AddOn,
|
|
13
|
+
Environment,
|
|
14
|
+
Integration,
|
|
15
|
+
IntegrationWithSource,
|
|
16
|
+
Options,
|
|
17
|
+
} from './types.js'
|
|
18
|
+
|
|
19
|
+
function convertDotFilesAndPaths(path: string) {
|
|
20
|
+
return path
|
|
21
|
+
.split('/')
|
|
22
|
+
.map((segment) => segment.replace(/^_dot_/, '.'))
|
|
23
|
+
.join('/')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizeSourceExtension(target: string, typescript: boolean) {
|
|
27
|
+
if (!typescript) {
|
|
28
|
+
return target
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const normalizedTarget = target.replace(/\\/g, '/')
|
|
32
|
+
|
|
33
|
+
if (!normalizedTarget.startsWith('src/')) {
|
|
34
|
+
return target
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (normalizedTarget.endsWith('.js')) {
|
|
38
|
+
return `${target.slice(0, -3)}.ts`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (normalizedTarget.endsWith('.jsx')) {
|
|
42
|
+
return `${target.slice(0, -4)}.tsx`
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return target
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createTemplateFile(environment: Environment, options: Options) {
|
|
49
|
+
function getPackageManagerAddScript(
|
|
50
|
+
packageName: string,
|
|
51
|
+
isDev: boolean = false,
|
|
52
|
+
) {
|
|
53
|
+
return formatCommand(
|
|
54
|
+
getPackageManagerInstallCommand(
|
|
55
|
+
options.packageManager,
|
|
56
|
+
packageName,
|
|
57
|
+
isDev,
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
function getPackageManagerRunScript(
|
|
62
|
+
scriptName: string,
|
|
63
|
+
args: Array<string> = [],
|
|
64
|
+
) {
|
|
65
|
+
return formatCommand(
|
|
66
|
+
getPackageManagerScriptCommand(options.packageManager, [
|
|
67
|
+
scriptName,
|
|
68
|
+
...args,
|
|
69
|
+
]),
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
function getPackageManagerExecuteScript(
|
|
73
|
+
pkg: string,
|
|
74
|
+
args: Array<string> = [],
|
|
75
|
+
) {
|
|
76
|
+
return formatCommand(
|
|
77
|
+
getPackageManagerExecuteCommand(options.packageManager, pkg, args),
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class IgnoreFileError extends Error {
|
|
82
|
+
constructor() {
|
|
83
|
+
super('ignoreFile')
|
|
84
|
+
this.name = 'IgnoreFileError'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const integrations: Array<IntegrationWithSource> = []
|
|
89
|
+
for (const addOn of options.chosenAddOns) {
|
|
90
|
+
if (addOn.integrations) {
|
|
91
|
+
for (const integration of addOn.integrations) {
|
|
92
|
+
integrations.push({
|
|
93
|
+
...integration,
|
|
94
|
+
_sourceId: addOn.id,
|
|
95
|
+
_sourceName: addOn.name,
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const routes: Array<Required<AddOn>['routes'][number]> = []
|
|
102
|
+
for (const addOn of options.chosenAddOns) {
|
|
103
|
+
if (addOn.routes) {
|
|
104
|
+
routes.push(...addOn.routes)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const addOnEnabled = options.chosenAddOns.reduce<Record<string, boolean>>(
|
|
109
|
+
(acc, addOn) => {
|
|
110
|
+
acc[addOn.id] = true
|
|
111
|
+
return acc
|
|
112
|
+
},
|
|
113
|
+
{},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return async function templateFile(file: string, content: string) {
|
|
117
|
+
const localRelativePath = (path: string, stripExtension: boolean = false) =>
|
|
118
|
+
relativePath(file, path, stripExtension)
|
|
119
|
+
|
|
120
|
+
const integrationImportContent = (integration: Integration) =>
|
|
121
|
+
integration.import ||
|
|
122
|
+
`import ${integration.jsName} from '${localRelativePath(integration.path || '')}'`
|
|
123
|
+
|
|
124
|
+
const integrationImportCode = (integration: Integration) =>
|
|
125
|
+
integration.code || integration.jsName
|
|
126
|
+
|
|
127
|
+
const templateValues = {
|
|
128
|
+
packageManager: options.packageManager,
|
|
129
|
+
projectName: options.projectName,
|
|
130
|
+
typescript: true,
|
|
131
|
+
tailwind: true,
|
|
132
|
+
js: 'ts',
|
|
133
|
+
jsx: 'tsx',
|
|
134
|
+
fileRouter: options.mode === 'file-router',
|
|
135
|
+
codeRouter: options.mode === 'code-router',
|
|
136
|
+
routerOnly: options.routerOnly === true,
|
|
137
|
+
includeExamples: options.includeExamples !== false,
|
|
138
|
+
addOnEnabled,
|
|
139
|
+
addOnOption: options.addOnOptions,
|
|
140
|
+
addOns: options.chosenAddOns,
|
|
141
|
+
integrations,
|
|
142
|
+
routes,
|
|
143
|
+
|
|
144
|
+
getPackageManagerAddScript,
|
|
145
|
+
getPackageManagerRunScript,
|
|
146
|
+
getPackageManagerExecuteScript,
|
|
147
|
+
|
|
148
|
+
relativePath: (path: string, stripExtension: boolean = false) =>
|
|
149
|
+
relativePath(file, path, stripExtension),
|
|
150
|
+
|
|
151
|
+
integrationImportContent,
|
|
152
|
+
integrationImportCode,
|
|
153
|
+
|
|
154
|
+
renderTemplate: (templateContent: string) => {
|
|
155
|
+
return render(templateContent, templateValues)
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
ignoreFile: () => {
|
|
159
|
+
throw new IgnoreFileError()
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let ignoreFile = false
|
|
164
|
+
|
|
165
|
+
if (file.endsWith('.ejs')) {
|
|
166
|
+
try {
|
|
167
|
+
content = render(content, templateValues)
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error instanceof IgnoreFileError) {
|
|
170
|
+
ignoreFile = true
|
|
171
|
+
} else {
|
|
172
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
173
|
+
environment.error(`EJS error in file ${file}`, message)
|
|
174
|
+
throw error
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (ignoreFile) {
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let target = convertDotFilesAndPaths(file.replace('.ejs', ''))
|
|
184
|
+
target = normalizeSourceExtension(target, options.typescript)
|
|
185
|
+
|
|
186
|
+
const prefixMatch = target.match(/^(.+\/)?__([^_]+)__(.+)$/)
|
|
187
|
+
if (prefixMatch) {
|
|
188
|
+
const [, directory, , filename] = prefixMatch
|
|
189
|
+
target = (directory || '') + filename
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let append = false
|
|
193
|
+
if (target.endsWith('.append')) {
|
|
194
|
+
append = true
|
|
195
|
+
target = target.replace('.append', '')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (append) {
|
|
199
|
+
await environment.appendFile(joinPaths(options.targetDir, target), content)
|
|
200
|
+
} else {
|
|
201
|
+
await environment.writeFile(joinPaths(options.targetDir, target), content)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
package/src/edge.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { createApp } from './edge-create-app.js'
|
|
2
|
+
export {
|
|
3
|
+
createMemoryEnvironment,
|
|
4
|
+
type MemoryEnvironmentOutput,
|
|
5
|
+
} from './edge-environment.js'
|
|
6
|
+
export {
|
|
7
|
+
getFrameworkById,
|
|
8
|
+
getFrameworkByName,
|
|
9
|
+
getFrameworks,
|
|
10
|
+
} from './edge-frameworks.js'
|
|
11
|
+
export {
|
|
12
|
+
finalizeAddOns,
|
|
13
|
+
getAllAddOns,
|
|
14
|
+
loadRemoteAddOn,
|
|
15
|
+
populateAddOnOptionsDefaults,
|
|
16
|
+
} from './edge-add-ons.js'
|
|
17
|
+
export { createSerializedOptions } from './options.js'
|
|
18
|
+
export { CONFIG_FILE } from './constants.js'
|
|
19
|
+
export {
|
|
20
|
+
DEFAULT_PACKAGE_MANAGER,
|
|
21
|
+
SUPPORTED_PACKAGE_MANAGERS,
|
|
22
|
+
getPackageManagerExecuteCommand,
|
|
23
|
+
getPackageManagerInstallCommand,
|
|
24
|
+
getPackageManagerScriptCommand,
|
|
25
|
+
translateExecuteCommand,
|
|
26
|
+
} from './package-manager.js'
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
AddOn,
|
|
30
|
+
AddOnOption,
|
|
31
|
+
AddOnOptions,
|
|
32
|
+
AddOnSelectOption,
|
|
33
|
+
AddOnSelection,
|
|
34
|
+
Environment,
|
|
35
|
+
FileBundleHandler,
|
|
36
|
+
Framework,
|
|
37
|
+
FrameworkDefinition,
|
|
38
|
+
Options,
|
|
39
|
+
SerializedOptions,
|
|
40
|
+
Starter,
|
|
41
|
+
StarterCompiled,
|
|
42
|
+
} from './types.js'
|
|
43
|
+
export type { PackageManager } from './package-manager.js'
|
|
@@ -7,14 +7,9 @@
|
|
|
7
7
|
"type": "add-on",
|
|
8
8
|
"category": "tooling",
|
|
9
9
|
"color": "#FF4785",
|
|
10
|
-
"priority":
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"name": "Storybook",
|
|
16
|
-
"path": "src/routes/demo.storybook.tsx",
|
|
17
|
-
"jsName": "StorybookDemo"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
10
|
+
"priority": 1,
|
|
11
|
+
"command": {
|
|
12
|
+
"command": "npx",
|
|
13
|
+
"args": ["storybook", "init", "-y", "--no-dev"]
|
|
14
|
+
}
|
|
20
15
|
}
|