@cedarjs/project-config 0.0.4
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/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/cjs/config.d.ts +126 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/configPath.d.ts +5 -0
- package/dist/cjs/configPath.d.ts.map +1 -0
- package/dist/cjs/findUp.d.ts +5 -0
- package/dist/cjs/findUp.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +472 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/paths.d.ts +142 -0
- package/dist/cjs/paths.d.ts.map +1 -0
- package/dist/config.d.ts +126 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/configPath.d.ts +5 -0
- package/dist/configPath.d.ts.map +1 -0
- package/dist/findUp.d.ts +5 -0
- package/dist/findUp.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +418 -0
- package/dist/package.json +1 -0
- package/dist/paths.d.ts +142 -0
- package/dist/paths.d.ts.map +1 -0
- package/package.json +58 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import fs2 from "fs";
|
|
3
|
+
import merge from "deepmerge";
|
|
4
|
+
import * as toml from "smol-toml";
|
|
5
|
+
import { env as envInterpolation } from "string-env-interpolation";
|
|
6
|
+
|
|
7
|
+
// src/findUp.ts
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
function findUp(file, startingDirectory = process.cwd()) {
|
|
11
|
+
const possibleFilepath = path.join(startingDirectory, file);
|
|
12
|
+
if (fs.existsSync(possibleFilepath)) {
|
|
13
|
+
return possibleFilepath;
|
|
14
|
+
}
|
|
15
|
+
const parentDirectory = path.dirname(startingDirectory);
|
|
16
|
+
if (parentDirectory === startingDirectory) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return findUp(file, parentDirectory);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/configPath.ts
|
|
23
|
+
var CONFIG_FILE_NAME = "redwood.toml";
|
|
24
|
+
var getConfigPathCache = /* @__PURE__ */ new Map();
|
|
25
|
+
var getConfigPath = (cwd = process.env.RWJS_CWD ?? process.cwd()) => {
|
|
26
|
+
const cachedPath = getConfigPathCache.get(cwd);
|
|
27
|
+
if (cachedPath) {
|
|
28
|
+
return cachedPath;
|
|
29
|
+
}
|
|
30
|
+
const configPath = findUp(CONFIG_FILE_NAME, cwd);
|
|
31
|
+
if (!configPath) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Could not find a "${CONFIG_FILE_NAME}" file, are you sure you're in a Redwood project?`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
getConfigPathCache.set(cwd, configPath);
|
|
37
|
+
return configPath;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/config.ts
|
|
41
|
+
var TargetEnum = /* @__PURE__ */ ((TargetEnum2) => {
|
|
42
|
+
TargetEnum2["NODE"] = "node";
|
|
43
|
+
TargetEnum2["BROWSER"] = "browser";
|
|
44
|
+
TargetEnum2["REACT_NATIVE"] = "react-native";
|
|
45
|
+
TargetEnum2["ELECTRON"] = "electron";
|
|
46
|
+
return TargetEnum2;
|
|
47
|
+
})(TargetEnum || {});
|
|
48
|
+
var DEFAULT_CONFIG = {
|
|
49
|
+
web: {
|
|
50
|
+
title: "Redwood App",
|
|
51
|
+
port: 8910,
|
|
52
|
+
path: "./web",
|
|
53
|
+
target: "browser" /* BROWSER */,
|
|
54
|
+
includeEnvironmentVariables: [],
|
|
55
|
+
apiUrl: "/.redwood/functions",
|
|
56
|
+
fastRefresh: true,
|
|
57
|
+
a11y: true,
|
|
58
|
+
sourceMap: false
|
|
59
|
+
},
|
|
60
|
+
api: {
|
|
61
|
+
title: "Redwood App",
|
|
62
|
+
port: 8911,
|
|
63
|
+
path: "./api",
|
|
64
|
+
target: "node" /* NODE */,
|
|
65
|
+
schemaPath: "./api/db/schema.prisma",
|
|
66
|
+
serverConfig: "./api/server.config.js",
|
|
67
|
+
debugPort: 18911
|
|
68
|
+
},
|
|
69
|
+
graphql: {
|
|
70
|
+
fragments: false,
|
|
71
|
+
trustedDocuments: false,
|
|
72
|
+
includeScalars: { File: true }
|
|
73
|
+
},
|
|
74
|
+
browser: {
|
|
75
|
+
open: false
|
|
76
|
+
},
|
|
77
|
+
generate: {
|
|
78
|
+
tests: true,
|
|
79
|
+
stories: true,
|
|
80
|
+
nestScaffoldByModel: true
|
|
81
|
+
},
|
|
82
|
+
notifications: {
|
|
83
|
+
versionUpdates: []
|
|
84
|
+
},
|
|
85
|
+
studio: {
|
|
86
|
+
basePort: 4318,
|
|
87
|
+
graphiql: {
|
|
88
|
+
authImpersonation: {
|
|
89
|
+
authProvider: void 0,
|
|
90
|
+
userId: void 0,
|
|
91
|
+
email: void 0,
|
|
92
|
+
jwtSecret: "secret"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
experimental: {
|
|
97
|
+
opentelemetry: {
|
|
98
|
+
enabled: false,
|
|
99
|
+
wrapApi: true
|
|
100
|
+
},
|
|
101
|
+
cli: {
|
|
102
|
+
autoInstall: true,
|
|
103
|
+
plugins: [
|
|
104
|
+
{
|
|
105
|
+
package: "@cedarjs/cli-storybook-vite"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
package: "@cedarjs/cli-data-migrate"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
useSDLCodeGenForGraphQLTypes: false,
|
|
113
|
+
streamingSsr: {
|
|
114
|
+
enabled: false
|
|
115
|
+
},
|
|
116
|
+
rsc: {
|
|
117
|
+
enabled: false
|
|
118
|
+
},
|
|
119
|
+
realtime: {
|
|
120
|
+
enabled: false
|
|
121
|
+
},
|
|
122
|
+
reactCompiler: {
|
|
123
|
+
enabled: false,
|
|
124
|
+
lintOnly: false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
var getConfig = (configPath = getConfigPath()) => {
|
|
129
|
+
try {
|
|
130
|
+
return merge(DEFAULT_CONFIG, getRawConfig(configPath));
|
|
131
|
+
} catch (e) {
|
|
132
|
+
throw new Error(`Could not parse "${configPath}": ${e}`);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
function getRawConfig(configPath = getConfigPath()) {
|
|
136
|
+
try {
|
|
137
|
+
return toml.parse(envInterpolation(fs2.readFileSync(configPath, "utf8")));
|
|
138
|
+
} catch (e) {
|
|
139
|
+
throw new Error(`Could not parse "${configPath}": ${e}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/paths.ts
|
|
144
|
+
import fs3 from "fs";
|
|
145
|
+
import path2 from "path";
|
|
146
|
+
import fg from "fast-glob";
|
|
147
|
+
var PATH_API_DIR_FUNCTIONS = "api/src/functions";
|
|
148
|
+
var PATH_RW_SCRIPTS = "scripts";
|
|
149
|
+
var PATH_API_DIR_GRAPHQL = "api/src/graphql";
|
|
150
|
+
var PATH_API_DIR_CONFIG = "api/src/config";
|
|
151
|
+
var PATH_API_DIR_MODELS = "api/src/models";
|
|
152
|
+
var PATH_API_DIR_JOBS = "api/src/jobs";
|
|
153
|
+
var PATH_API_DIR_LIB = "api/src/lib";
|
|
154
|
+
var PATH_API_DIR_GENERATORS = "api/generators";
|
|
155
|
+
var PATH_API_DIR_SERVICES = "api/src/services";
|
|
156
|
+
var PATH_API_DIR_DIRECTIVES = "api/src/directives";
|
|
157
|
+
var PATH_API_DIR_SUBSCRIPTIONS = "api/src/subscriptions";
|
|
158
|
+
var PATH_API_DIR_SRC = "api/src";
|
|
159
|
+
var PATH_API_DIR_DIST = "api/dist";
|
|
160
|
+
var PATH_WEB_ROUTES = "web/src/Routes";
|
|
161
|
+
var PATH_WEB_DIR_LAYOUTS = "web/src/layouts/";
|
|
162
|
+
var PATH_WEB_DIR_PAGES = "web/src/pages/";
|
|
163
|
+
var PATH_WEB_DIR_COMPONENTS = "web/src/components";
|
|
164
|
+
var PATH_WEB_DIR_STORYBOOK_CONFIG = "web/.storybook";
|
|
165
|
+
var PATH_WEB_DIR_SRC = "web/src";
|
|
166
|
+
var PATH_WEB_DIR_SRC_APP = "web/src/App";
|
|
167
|
+
var PATH_WEB_DIR_SRC_DOCUMENT = "web/src/Document";
|
|
168
|
+
var PATH_WEB_INDEX_HTML = "web/src/index.html";
|
|
169
|
+
var PATH_WEB_DIR_GENERATORS = "web/generators";
|
|
170
|
+
var PATH_WEB_DIR_CONFIG = "web/config";
|
|
171
|
+
var PATH_WEB_DIR_CONFIG_VITE = "web/vite.config";
|
|
172
|
+
var PATH_WEB_DIR_ENTRY_CLIENT = "web/src/entry.client";
|
|
173
|
+
var PATH_WEB_DIR_ENTRY_SERVER = "web/src/entry.server";
|
|
174
|
+
var PATH_WEB_DIR_GRAPHQL = "web/src/graphql";
|
|
175
|
+
var PATH_WEB_DIR_CONFIG_POSTCSS = "web/config/postcss.config.js";
|
|
176
|
+
var PATH_WEB_DIR_CONFIG_STORYBOOK_CONFIG = "web/.storybook/main.js";
|
|
177
|
+
var PATH_WEB_DIR_CONFIG_STORYBOOK_PREVIEW = "web/.storybook/preview";
|
|
178
|
+
var PATH_WEB_DIR_CONFIG_STORYBOOK_MANAGER = "web/.storybook/manager.js";
|
|
179
|
+
var PATH_WEB_DIR_DIST = "web/dist";
|
|
180
|
+
var PATH_WEB_DIR_DIST_BROWSER = "web/dist/browser";
|
|
181
|
+
var PATH_WEB_DIR_DIST_RSC = "web/dist/rsc";
|
|
182
|
+
var PATH_WEB_DIR_DIST_SSR = "web/dist/ssr";
|
|
183
|
+
var PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER = "web/dist/ssr/entry.server.mjs";
|
|
184
|
+
var PATH_WEB_DIR_DIST_SSR_DOCUMENT = "web/dist/ssr/Document.mjs";
|
|
185
|
+
var PATH_WEB_DIR_DIST_SSR_ROUTEHOOKS = "web/dist/ssr/routeHooks";
|
|
186
|
+
var PATH_WEB_DIR_DIST_RSC_ENTRIES = "web/dist/rsc/entries.mjs";
|
|
187
|
+
var PATH_WEB_DIR_ROUTE_MANIFEST = "web/dist/ssr/route-manifest.json";
|
|
188
|
+
var getBaseDir = (configPath = getConfigPath()) => {
|
|
189
|
+
return path2.dirname(configPath);
|
|
190
|
+
};
|
|
191
|
+
var getBaseDirFromFile = (file) => {
|
|
192
|
+
return getBaseDir(getConfigPath(path2.dirname(file)));
|
|
193
|
+
};
|
|
194
|
+
var resolveFile = (filePath, extensions = [".js", ".tsx", ".ts", ".jsx", ".mjs", ".mts"]) => {
|
|
195
|
+
for (const extension of extensions) {
|
|
196
|
+
const p = `${filePath}${extension}`;
|
|
197
|
+
if (fs3.existsSync(p)) {
|
|
198
|
+
return p;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
};
|
|
203
|
+
var getPathsCache = /* @__PURE__ */ new Map();
|
|
204
|
+
var getPaths = (BASE_DIR = getBaseDir()) => {
|
|
205
|
+
if (getPathsCache.has(BASE_DIR)) {
|
|
206
|
+
return getPathsCache.get(BASE_DIR);
|
|
207
|
+
}
|
|
208
|
+
const routes = resolveFile(path2.join(BASE_DIR, PATH_WEB_ROUTES));
|
|
209
|
+
const { schemaPath } = getConfig(getConfigPath(BASE_DIR)).api;
|
|
210
|
+
const schemaDir = path2.dirname(schemaPath);
|
|
211
|
+
const viteConfig = resolveFile(
|
|
212
|
+
path2.join(BASE_DIR, PATH_WEB_DIR_CONFIG_VITE)
|
|
213
|
+
);
|
|
214
|
+
const paths = {
|
|
215
|
+
base: BASE_DIR,
|
|
216
|
+
generated: {
|
|
217
|
+
base: path2.join(BASE_DIR, ".redwood"),
|
|
218
|
+
schema: path2.join(BASE_DIR, ".redwood/schema.graphql"),
|
|
219
|
+
types: {
|
|
220
|
+
includes: path2.join(BASE_DIR, ".redwood/types/includes"),
|
|
221
|
+
mirror: path2.join(BASE_DIR, ".redwood/types/mirror")
|
|
222
|
+
},
|
|
223
|
+
prebuild: path2.join(BASE_DIR, ".redwood/prebuild")
|
|
224
|
+
},
|
|
225
|
+
scripts: path2.join(BASE_DIR, PATH_RW_SCRIPTS),
|
|
226
|
+
api: {
|
|
227
|
+
base: path2.join(BASE_DIR, "api"),
|
|
228
|
+
dataMigrations: path2.join(BASE_DIR, schemaDir, "dataMigrations"),
|
|
229
|
+
db: path2.join(BASE_DIR, schemaDir),
|
|
230
|
+
dbSchema: path2.join(BASE_DIR, schemaPath),
|
|
231
|
+
functions: path2.join(BASE_DIR, PATH_API_DIR_FUNCTIONS),
|
|
232
|
+
graphql: path2.join(BASE_DIR, PATH_API_DIR_GRAPHQL),
|
|
233
|
+
lib: path2.join(BASE_DIR, PATH_API_DIR_LIB),
|
|
234
|
+
generators: path2.join(BASE_DIR, PATH_API_DIR_GENERATORS),
|
|
235
|
+
config: path2.join(BASE_DIR, PATH_API_DIR_CONFIG),
|
|
236
|
+
services: path2.join(BASE_DIR, PATH_API_DIR_SERVICES),
|
|
237
|
+
directives: path2.join(BASE_DIR, PATH_API_DIR_DIRECTIVES),
|
|
238
|
+
subscriptions: path2.join(BASE_DIR, PATH_API_DIR_SUBSCRIPTIONS),
|
|
239
|
+
src: path2.join(BASE_DIR, PATH_API_DIR_SRC),
|
|
240
|
+
dist: path2.join(BASE_DIR, PATH_API_DIR_DIST),
|
|
241
|
+
types: path2.join(BASE_DIR, "api/types"),
|
|
242
|
+
models: path2.join(BASE_DIR, PATH_API_DIR_MODELS),
|
|
243
|
+
mail: path2.join(BASE_DIR, PATH_API_DIR_SRC, "mail"),
|
|
244
|
+
jobs: path2.join(path2.join(BASE_DIR, PATH_API_DIR_JOBS)),
|
|
245
|
+
distJobs: path2.join(path2.join(BASE_DIR, PATH_API_DIR_DIST, "jobs")),
|
|
246
|
+
jobsConfig: resolveFile(path2.join(BASE_DIR, PATH_API_DIR_LIB, "jobs")),
|
|
247
|
+
distJobsConfig: resolveFile(
|
|
248
|
+
path2.join(BASE_DIR, PATH_API_DIR_DIST, "lib", "jobs")
|
|
249
|
+
),
|
|
250
|
+
logger: resolveFile(path2.join(BASE_DIR, PATH_API_DIR_LIB, "logger"))
|
|
251
|
+
},
|
|
252
|
+
web: {
|
|
253
|
+
routes,
|
|
254
|
+
base: path2.join(BASE_DIR, "web"),
|
|
255
|
+
pages: path2.join(BASE_DIR, PATH_WEB_DIR_PAGES),
|
|
256
|
+
components: path2.join(BASE_DIR, PATH_WEB_DIR_COMPONENTS),
|
|
257
|
+
layouts: path2.join(BASE_DIR, PATH_WEB_DIR_LAYOUTS),
|
|
258
|
+
src: path2.join(BASE_DIR, PATH_WEB_DIR_SRC),
|
|
259
|
+
storybook: path2.join(BASE_DIR, PATH_WEB_DIR_STORYBOOK_CONFIG),
|
|
260
|
+
generators: path2.join(BASE_DIR, PATH_WEB_DIR_GENERATORS),
|
|
261
|
+
app: resolveFile(path2.join(BASE_DIR, PATH_WEB_DIR_SRC_APP)),
|
|
262
|
+
document: resolveFile(
|
|
263
|
+
path2.join(BASE_DIR, PATH_WEB_DIR_SRC_DOCUMENT)
|
|
264
|
+
),
|
|
265
|
+
html: path2.join(BASE_DIR, PATH_WEB_INDEX_HTML),
|
|
266
|
+
config: path2.join(BASE_DIR, PATH_WEB_DIR_CONFIG),
|
|
267
|
+
viteConfig,
|
|
268
|
+
postcss: path2.join(BASE_DIR, PATH_WEB_DIR_CONFIG_POSTCSS),
|
|
269
|
+
storybookConfig: path2.join(
|
|
270
|
+
BASE_DIR,
|
|
271
|
+
PATH_WEB_DIR_CONFIG_STORYBOOK_CONFIG
|
|
272
|
+
),
|
|
273
|
+
storybookPreviewConfig: resolveFile(
|
|
274
|
+
path2.join(BASE_DIR, PATH_WEB_DIR_CONFIG_STORYBOOK_PREVIEW)
|
|
275
|
+
),
|
|
276
|
+
storybookManagerConfig: path2.join(
|
|
277
|
+
BASE_DIR,
|
|
278
|
+
PATH_WEB_DIR_CONFIG_STORYBOOK_MANAGER
|
|
279
|
+
),
|
|
280
|
+
dist: path2.join(BASE_DIR, PATH_WEB_DIR_DIST),
|
|
281
|
+
distBrowser: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_BROWSER),
|
|
282
|
+
distRsc: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC),
|
|
283
|
+
distSsr: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR),
|
|
284
|
+
distSsrDocument: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_DOCUMENT),
|
|
285
|
+
distSsrEntryServer: path2.join(
|
|
286
|
+
BASE_DIR,
|
|
287
|
+
PATH_WEB_DIR_DIST_SSR_ENTRY_SERVER
|
|
288
|
+
),
|
|
289
|
+
distRouteHooks: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_SSR_ROUTEHOOKS),
|
|
290
|
+
distRscEntries: path2.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC_ENTRIES),
|
|
291
|
+
routeManifest: path2.join(BASE_DIR, PATH_WEB_DIR_ROUTE_MANIFEST),
|
|
292
|
+
types: path2.join(BASE_DIR, "web/types"),
|
|
293
|
+
entryClient: resolveFile(path2.join(BASE_DIR, PATH_WEB_DIR_ENTRY_CLIENT)),
|
|
294
|
+
// new vite/stream entry point for client
|
|
295
|
+
entryServer: resolveFile(path2.join(BASE_DIR, PATH_WEB_DIR_ENTRY_SERVER)),
|
|
296
|
+
graphql: path2.join(BASE_DIR, PATH_WEB_DIR_GRAPHQL)
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
fs3.mkdirSync(paths.generated.types.includes, { recursive: true });
|
|
300
|
+
fs3.mkdirSync(paths.generated.types.mirror, { recursive: true });
|
|
301
|
+
getPathsCache.set(BASE_DIR, paths);
|
|
302
|
+
return paths;
|
|
303
|
+
};
|
|
304
|
+
var getRouteHookForPage = (pagePath) => {
|
|
305
|
+
if (!pagePath) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
return fg.sync("*.routeHooks.{js,ts,tsx,jsx}", {
|
|
309
|
+
absolute: true,
|
|
310
|
+
cwd: path2.dirname(pagePath)
|
|
311
|
+
// the page's folder
|
|
312
|
+
}).at(0) || null;
|
|
313
|
+
};
|
|
314
|
+
var getAppRouteHook = (forProd = false) => {
|
|
315
|
+
const rwPaths = getPaths();
|
|
316
|
+
if (forProd) {
|
|
317
|
+
const distAppRouteHook = path2.join(
|
|
318
|
+
rwPaths.web.distRouteHooks,
|
|
319
|
+
"App.routeHooks.js"
|
|
320
|
+
);
|
|
321
|
+
try {
|
|
322
|
+
fs3.statSync(distAppRouteHook).isFile();
|
|
323
|
+
return distAppRouteHook;
|
|
324
|
+
} catch {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return resolveFile(path2.join(rwPaths.web.src, "App.routeHooks"));
|
|
329
|
+
};
|
|
330
|
+
var processPagesDir = (webPagesDir = getPaths().web.pages) => {
|
|
331
|
+
const pagePaths = fg.sync("**/*Page.{js,jsx,ts,tsx}", {
|
|
332
|
+
cwd: webPagesDir,
|
|
333
|
+
ignore: ["node_modules"]
|
|
334
|
+
});
|
|
335
|
+
return pagePaths.map((pagePath) => {
|
|
336
|
+
const p = path2.parse(pagePath);
|
|
337
|
+
const importName = p.dir.replace(/\//g, "");
|
|
338
|
+
const importPath = importStatementPath(
|
|
339
|
+
path2.join(webPagesDir, p.dir, p.name)
|
|
340
|
+
);
|
|
341
|
+
const importStatement = `const ${importName} = { name: '${importName}', loader: import('${importPath}') }`;
|
|
342
|
+
return {
|
|
343
|
+
importName,
|
|
344
|
+
constName: importName,
|
|
345
|
+
importPath,
|
|
346
|
+
path: path2.join(webPagesDir, pagePath),
|
|
347
|
+
importStatement
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
var ensurePosixPath = (path3) => {
|
|
352
|
+
let posixPath = path3;
|
|
353
|
+
if (process.platform === "win32") {
|
|
354
|
+
if (/^[A-Z]:\\/.test(path3)) {
|
|
355
|
+
const drive = path3[0].toLowerCase();
|
|
356
|
+
posixPath = `/${drive}/${path3.substring(3)}`;
|
|
357
|
+
}
|
|
358
|
+
posixPath = posixPath.replace(/\\/g, "/");
|
|
359
|
+
}
|
|
360
|
+
return posixPath;
|
|
361
|
+
};
|
|
362
|
+
var importStatementPath = (path3) => {
|
|
363
|
+
let importPath = path3;
|
|
364
|
+
if (process.platform === "win32") {
|
|
365
|
+
importPath = importPath.replaceAll("\\", "/");
|
|
366
|
+
}
|
|
367
|
+
return importPath;
|
|
368
|
+
};
|
|
369
|
+
function packageJsonIsEsm(packageJsonPath) {
|
|
370
|
+
const packageJsonContents = JSON.parse(
|
|
371
|
+
fs3.readFileSync(packageJsonPath, "utf-8")
|
|
372
|
+
);
|
|
373
|
+
return packageJsonContents.type === "module";
|
|
374
|
+
}
|
|
375
|
+
function projectRootIsEsm() {
|
|
376
|
+
return packageJsonIsEsm(path2.join(getPaths().base, "package.json"));
|
|
377
|
+
}
|
|
378
|
+
function projectSideIsEsm(side) {
|
|
379
|
+
const redwoodProjectPaths = getPaths();
|
|
380
|
+
return packageJsonIsEsm(
|
|
381
|
+
path2.join(redwoodProjectPaths[side].base, "package.json")
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
function projectIsEsm() {
|
|
385
|
+
if (!projectRootIsEsm()) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
for (const side of ["api", "web"]) {
|
|
389
|
+
if (!projectSideIsEsm(side)) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
var isTypeScriptProject = () => {
|
|
396
|
+
const paths = getPaths();
|
|
397
|
+
return fs3.existsSync(path2.join(paths.web.base, "tsconfig.json")) || fs3.existsSync(path2.join(paths.api.base, "tsconfig.json"));
|
|
398
|
+
};
|
|
399
|
+
export {
|
|
400
|
+
TargetEnum,
|
|
401
|
+
ensurePosixPath,
|
|
402
|
+
findUp,
|
|
403
|
+
getAppRouteHook,
|
|
404
|
+
getBaseDir,
|
|
405
|
+
getBaseDirFromFile,
|
|
406
|
+
getConfig,
|
|
407
|
+
getConfigPath,
|
|
408
|
+
getPaths,
|
|
409
|
+
getRawConfig,
|
|
410
|
+
getRouteHookForPage,
|
|
411
|
+
importStatementPath,
|
|
412
|
+
isTypeScriptProject,
|
|
413
|
+
processPagesDir,
|
|
414
|
+
projectIsEsm,
|
|
415
|
+
projectRootIsEsm,
|
|
416
|
+
projectSideIsEsm,
|
|
417
|
+
resolveFile
|
|
418
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export interface NodeTargetPaths {
|
|
2
|
+
base: string;
|
|
3
|
+
dataMigrations: string;
|
|
4
|
+
directives: string;
|
|
5
|
+
db: string;
|
|
6
|
+
dbSchema: string;
|
|
7
|
+
src: string;
|
|
8
|
+
functions: string;
|
|
9
|
+
graphql: string;
|
|
10
|
+
lib: string;
|
|
11
|
+
generators: string;
|
|
12
|
+
services: string;
|
|
13
|
+
config: string;
|
|
14
|
+
dist: string;
|
|
15
|
+
types: string;
|
|
16
|
+
models: string;
|
|
17
|
+
mail: string;
|
|
18
|
+
jobs: string;
|
|
19
|
+
distJobs: string;
|
|
20
|
+
jobsConfig: string | null;
|
|
21
|
+
distJobsConfig: string | null;
|
|
22
|
+
logger: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface WebPaths {
|
|
25
|
+
base: string;
|
|
26
|
+
src: string;
|
|
27
|
+
storybook: string;
|
|
28
|
+
app: string;
|
|
29
|
+
document: string;
|
|
30
|
+
generators: string;
|
|
31
|
+
html: string;
|
|
32
|
+
routes: string;
|
|
33
|
+
pages: string;
|
|
34
|
+
components: string;
|
|
35
|
+
layouts: string;
|
|
36
|
+
config: string;
|
|
37
|
+
viteConfig: string;
|
|
38
|
+
entryClient: string | null;
|
|
39
|
+
entryServer: string | null;
|
|
40
|
+
postcss: string;
|
|
41
|
+
storybookConfig: string;
|
|
42
|
+
storybookPreviewConfig: string | null;
|
|
43
|
+
storybookManagerConfig: string;
|
|
44
|
+
dist: string;
|
|
45
|
+
distBrowser: string;
|
|
46
|
+
distRsc: string;
|
|
47
|
+
distSsr: string;
|
|
48
|
+
distSsrDocument: string;
|
|
49
|
+
distSsrEntryServer: string;
|
|
50
|
+
distRouteHooks: string;
|
|
51
|
+
distRscEntries: string;
|
|
52
|
+
routeManifest: string;
|
|
53
|
+
types: string;
|
|
54
|
+
graphql: string;
|
|
55
|
+
}
|
|
56
|
+
export interface Paths {
|
|
57
|
+
base: string;
|
|
58
|
+
generated: {
|
|
59
|
+
base: string;
|
|
60
|
+
schema: string;
|
|
61
|
+
types: {
|
|
62
|
+
includes: string;
|
|
63
|
+
mirror: string;
|
|
64
|
+
};
|
|
65
|
+
prebuild: string;
|
|
66
|
+
};
|
|
67
|
+
web: WebPaths;
|
|
68
|
+
api: NodeTargetPaths;
|
|
69
|
+
scripts: string;
|
|
70
|
+
}
|
|
71
|
+
export interface PagesDependency {
|
|
72
|
+
/** the variable to which the import is assigned */
|
|
73
|
+
importName: string;
|
|
74
|
+
/** @alias importName */
|
|
75
|
+
constName: string;
|
|
76
|
+
/** absolute path without extension */
|
|
77
|
+
importPath: string;
|
|
78
|
+
/** absolute path with extension */
|
|
79
|
+
path: string;
|
|
80
|
+
/** const ${importName} = { ...data structure for async imports... } */
|
|
81
|
+
importStatement: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The Redwood config file is used as an anchor for the base directory of a project.
|
|
85
|
+
*/
|
|
86
|
+
export declare const getBaseDir: (configPath?: string) => string;
|
|
87
|
+
export declare const getBaseDirFromFile: (file: string) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Use this to resolve files when the path to the file is known,
|
|
90
|
+
* but the extension is not.
|
|
91
|
+
*/
|
|
92
|
+
export declare const resolveFile: (filePath: string, extensions?: string[]) => string | null;
|
|
93
|
+
export declare const getPaths: (BASE_DIR?: string) => Paths;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the route hook for the supplied page path.
|
|
96
|
+
* Note that the page name doesn't have to match
|
|
97
|
+
*
|
|
98
|
+
* @param pagePath
|
|
99
|
+
* @returns string
|
|
100
|
+
*/
|
|
101
|
+
export declare const getRouteHookForPage: (pagePath: string | undefined | null) => string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Use this function to find the app route hook.
|
|
104
|
+
* If it is present, you get the path to the file - in prod, you get the built version in dist.
|
|
105
|
+
* In dev, you get the source version.
|
|
106
|
+
*
|
|
107
|
+
* @param forProd
|
|
108
|
+
* @returns string | null
|
|
109
|
+
*/
|
|
110
|
+
export declare const getAppRouteHook: (forProd?: boolean) => string | null;
|
|
111
|
+
/**
|
|
112
|
+
* Process the pages directory and return information useful for automated imports.
|
|
113
|
+
*
|
|
114
|
+
* Note: glob.sync returns posix style paths on Windows machines
|
|
115
|
+
* @deprecated I will write a seperate method that use `getFiles` instead. This
|
|
116
|
+
* is used by structure, babel auto-importer and the eslint plugin.
|
|
117
|
+
*/
|
|
118
|
+
export declare const processPagesDir: (webPagesDir?: string) => PagesDependency[];
|
|
119
|
+
/**
|
|
120
|
+
* Converts Windows-style paths to Posix-style
|
|
121
|
+
* C:\Users\Bob\dev\Redwood -> /c/Users/Bob/dev/Redwood
|
|
122
|
+
*
|
|
123
|
+
* The conversion only happens on Windows systems, and only for paths that are
|
|
124
|
+
* not already Posix-style
|
|
125
|
+
*
|
|
126
|
+
* @param path Filesystem path
|
|
127
|
+
*/
|
|
128
|
+
export declare const ensurePosixPath: (path: string) => string;
|
|
129
|
+
/**
|
|
130
|
+
* Switches backslash to regular slash on Windows so the path works in
|
|
131
|
+
* import statements
|
|
132
|
+
* C:\Users\Bob\dev\Redwood\UserPage\UserPage ->
|
|
133
|
+
* C:/Users/Bob/dev/Redwood/UserPage/UserPage
|
|
134
|
+
*
|
|
135
|
+
* @param path Filesystem path
|
|
136
|
+
*/
|
|
137
|
+
export declare const importStatementPath: (path: string) => string;
|
|
138
|
+
export declare function projectRootIsEsm(): boolean;
|
|
139
|
+
export declare function projectSideIsEsm(side: 'api' | 'web'): boolean;
|
|
140
|
+
export declare function projectIsEsm(): boolean;
|
|
141
|
+
export declare const isTypeScriptProject: () => boolean;
|
|
142
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cedarjs/project-config",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
|
+
"directory": "packages/project-config"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsx ./build.ts && run build:types",
|
|
29
|
+
"build:pack": "yarn pack -o cedar-project-config.tgz",
|
|
30
|
+
"build:types": "tsc --build --verbose ./tsconfig.json ./tsconfig.cjs.json",
|
|
31
|
+
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
32
|
+
"check:attw": "yarn attw -P",
|
|
33
|
+
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
34
|
+
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest watch"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"deepmerge": "4.3.1",
|
|
40
|
+
"fast-glob": "3.3.2",
|
|
41
|
+
"smol-toml": "1.3.1",
|
|
42
|
+
"string-env-interpolation": "1.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@arethetypeswrong/cli": "0.16.4",
|
|
46
|
+
"@cedarjs/framework-tools": "0.0.4",
|
|
47
|
+
"concurrently": "8.2.2",
|
|
48
|
+
"publint": "0.3.11",
|
|
49
|
+
"rimraf": "6.0.1",
|
|
50
|
+
"tsx": "4.19.3",
|
|
51
|
+
"typescript": "5.6.2",
|
|
52
|
+
"vitest": "2.1.9"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "5b4f77f985bd86ee31ee7338312627accf0cb85b"
|
|
58
|
+
}
|