-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
296 changed files
with
27,459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,5 @@ packages/create-redwood-app/create-redwood-app.tgz | |
**/meta.*.json | ||
|
||
.nx/cache | ||
|
||
!packages/cli/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var build_exports = {}; | ||
__export(build_exports, { | ||
builder: () => builder, | ||
command: () => command, | ||
description: () => description, | ||
handler: () => handler | ||
}); | ||
module.exports = __toCommonJS(build_exports); | ||
var import_terminal_link = __toESM(require("terminal-link")); | ||
var import_colors = __toESM(require("../lib/colors")); | ||
var import_exit = require("../lib/exit"); | ||
var import_project = require("../lib/project"); | ||
var import_checkNodeVersion = require("../middleware/checkNodeVersion"); | ||
const command = "build [side..]"; | ||
const description = "Build for production"; | ||
const builder = (yargs) => { | ||
const choices = (0, import_project.sides)(); | ||
yargs.positional("side", { | ||
choices, | ||
default: choices, | ||
description: "Which side(s) to build", | ||
type: "array" | ||
}).option("stats", { | ||
default: false, | ||
description: `Use ${(0, import_terminal_link.default)( | ||
"Webpack Bundle Analyzer", | ||
"https://github.com/webpack-contrib/webpack-bundle-analyzer" | ||
)}`, | ||
type: "boolean" | ||
}).option("verbose", { | ||
alias: "v", | ||
default: false, | ||
description: "Print more", | ||
type: "boolean" | ||
}).option("prerender", { | ||
default: true, | ||
description: "Prerender after building web", | ||
type: "boolean" | ||
}).option("prisma", { | ||
type: "boolean", | ||
alias: "db", | ||
default: true, | ||
description: "Generate the Prisma client" | ||
}).option("performance", { | ||
alias: "perf", | ||
type: "boolean", | ||
default: false, | ||
description: "Measure build performance" | ||
}).middleware(() => { | ||
const check = (0, import_checkNodeVersion.checkNodeVersion)(); | ||
if (check.ok) { | ||
return; | ||
} | ||
(0, import_exit.exitWithError)(void 0, { | ||
message: `${import_colors.default.error("Error")}: ${check.message}`, | ||
includeEpilogue: false | ||
}); | ||
}).epilogue( | ||
`Also see the ${(0, import_terminal_link.default)( | ||
"Redwood CLI Reference", | ||
"https://redwoodjs.com/docs/cli-commands#build" | ||
)}` | ||
); | ||
}; | ||
const handler = async (options) => { | ||
const { handler: handler2 } = await import("./buildHandler.js"); | ||
return handler2(options); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
builder, | ||
command, | ||
description, | ||
handler | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var buildHandler_exports = {}; | ||
__export(buildHandler_exports, { | ||
handler: () => handler | ||
}); | ||
module.exports = __toCommonJS(buildHandler_exports); | ||
var import_path = __toESM(require("path")); | ||
var import_execa = __toESM(require("execa")); | ||
var import_fs_extra = __toESM(require("fs-extra")); | ||
var import_listr2 = require("listr2"); | ||
var import_rimraf = require("rimraf"); | ||
var import_terminal_link = __toESM(require("terminal-link")); | ||
var import_cli_helpers = require("@redwoodjs/cli-helpers"); | ||
var import_api = require("@redwoodjs/internal/dist/build/api"); | ||
var import_generate = require("@redwoodjs/internal/dist/generate/generate"); | ||
var import_validateSchema = require("@redwoodjs/internal/dist/validateSchema"); | ||
var import_detection = require("@redwoodjs/prerender/detection"); | ||
var import_telemetry = require("@redwoodjs/telemetry"); | ||
var import_lib = require("../lib"); | ||
var import_generatePrismaClient = require("../lib/generatePrismaClient"); | ||
const handler = async ({ | ||
side = ["api", "web"], | ||
verbose = false, | ||
performance = false, | ||
stats = false, | ||
prisma = true, | ||
prerender | ||
}) => { | ||
(0, import_cli_helpers.recordTelemetryAttributes)({ | ||
command: "build", | ||
side: JSON.stringify(side), | ||
verbose, | ||
performance, | ||
stats, | ||
prisma, | ||
prerender | ||
}); | ||
const rwjsPaths = (0, import_lib.getPaths)(); | ||
const rwjsConfig = (0, import_lib.getConfig)(); | ||
const useFragments = rwjsConfig.graphql?.fragments; | ||
const useTrustedDocuments = rwjsConfig.graphql?.trustedDocuments; | ||
if (performance) { | ||
console.log("Measuring Web Build Performance..."); | ||
import_execa.default.sync( | ||
`yarn cross-env NODE_ENV=production webpack --config ${require.resolve("@redwoodjs/core/config/webpack.perf.js")}`, | ||
{ stdio: "inherit", shell: true, cwd: rwjsPaths.web.base } | ||
); | ||
return; | ||
} | ||
if (stats) { | ||
console.log("Building Web Stats..."); | ||
import_execa.default.sync( | ||
`yarn cross-env NODE_ENV=production webpack --config ${require.resolve("@redwoodjs/core/config/webpack.stats.js")}`, | ||
{ stdio: "inherit", shell: true, cwd: rwjsPaths.web.base } | ||
); | ||
return; | ||
} | ||
const prismaSchemaExists = import_fs_extra.default.existsSync(rwjsPaths.api.dbSchema); | ||
const prerenderRoutes = prerender && side.includes("web") ? (0, import_detection.detectPrerenderRoutes)() : []; | ||
const shouldGeneratePrismaClient = prisma && prismaSchemaExists && (side.includes("api") || prerenderRoutes.length > 0); | ||
const tasks = [ | ||
shouldGeneratePrismaClient && { | ||
title: "Generating Prisma Client...", | ||
task: () => { | ||
const { cmd, args } = (0, import_generatePrismaClient.generatePrismaCommand)(rwjsPaths.api.dbSchema); | ||
return (0, import_execa.default)(cmd, args, { | ||
stdio: verbose ? "inherit" : "pipe", | ||
shell: true, | ||
cwd: rwjsPaths.api.base | ||
}); | ||
} | ||
}, | ||
// If using GraphQL Fragments or Trusted Documents, then we need to use | ||
// codegen to generate the types needed for possible types and the | ||
// trusted document store hashes | ||
(useFragments || useTrustedDocuments) && { | ||
title: `Generating types needed for ${[ | ||
useFragments && "GraphQL Fragments", | ||
useTrustedDocuments && "Trusted Documents" | ||
].filter(Boolean).join(" and ")} support...`, | ||
task: async () => { | ||
await (0, import_generate.generate)(); | ||
} | ||
}, | ||
side.includes("api") && { | ||
title: "Verifying graphql schema...", | ||
task: import_validateSchema.loadAndValidateSdls | ||
}, | ||
side.includes("api") && { | ||
title: "Building API...", | ||
task: async () => { | ||
await (0, import_api.cleanApiBuild)(); | ||
const { errors, warnings } = await (0, import_api.buildApi)(); | ||
if (errors.length) { | ||
console.error(errors); | ||
} | ||
if (warnings.length) { | ||
console.warn(warnings); | ||
} | ||
} | ||
}, | ||
side.includes("web") && { | ||
// Clean web/dist before building | ||
// Vite handles this internally | ||
title: "Cleaning Web...", | ||
task: () => { | ||
return (0, import_rimraf.rimraf)(rwjsPaths.web.dist); | ||
}, | ||
enabled: (0, import_lib.getConfig)().web.bundler === "webpack" | ||
}, | ||
side.includes("web") && { | ||
title: "Building Web...", | ||
task: async () => { | ||
if ((0, import_lib.getConfig)().web.bundler !== "webpack") { | ||
process.env.VITE_CJS_IGNORE_WARNING = "true"; | ||
await (0, import_execa.default)( | ||
`node ${require.resolve("@redwoodjs/vite/bins/rw-vite-build.mjs")} --webDir="${rwjsPaths.web.base}" --verbose=${verbose}`, | ||
{ | ||
stdio: verbose ? "inherit" : "pipe", | ||
shell: true, | ||
// `cwd` is needed for yarn to find the rw-vite-build binary | ||
// It won't change process.cwd for anything else here, in this | ||
// process | ||
cwd: rwjsPaths.web.base | ||
} | ||
); | ||
} else { | ||
await (0, import_execa.default)( | ||
`yarn cross-env NODE_ENV=production webpack --config ${require.resolve("@redwoodjs/core/config/webpack.production.js")}`, | ||
{ | ||
stdio: verbose ? "inherit" : "pipe", | ||
shell: true, | ||
cwd: rwjsPaths.web.base | ||
} | ||
); | ||
} | ||
if (!(0, import_lib.getConfig)().experimental?.streamingSsr?.enabled) { | ||
console.log("Creating 200.html..."); | ||
const indexHtmlPath = import_path.default.join((0, import_lib.getPaths)().web.dist, "index.html"); | ||
import_fs_extra.default.copyFileSync( | ||
indexHtmlPath, | ||
import_path.default.join((0, import_lib.getPaths)().web.dist, "200.html") | ||
); | ||
} | ||
} | ||
} | ||
].filter(Boolean); | ||
const triggerPrerender = async () => { | ||
console.log("Starting prerendering..."); | ||
if (prerenderRoutes.length === 0) { | ||
console.log( | ||
`You have not marked any routes to "prerender" in your ${(0, import_terminal_link.default)( | ||
"Routes", | ||
"file://" + rwjsPaths.web.routes | ||
)}.` | ||
); | ||
return; | ||
} | ||
await (0, import_execa.default)("yarn rw prerender", { | ||
stdio: "inherit", | ||
shell: true, | ||
cwd: rwjsPaths.web.base | ||
}); | ||
}; | ||
const jobs = new import_listr2.Listr(tasks, { | ||
renderer: verbose && "verbose" | ||
}); | ||
await (0, import_telemetry.timedTelemetry)(process.argv, { type: "build" }, async () => { | ||
await jobs.run(); | ||
if (side.includes("web") && prerender && prismaSchemaExists) { | ||
await triggerPrerender(); | ||
} | ||
}); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
handler | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var check_exports = {}; | ||
__export(check_exports, { | ||
aliases: () => aliases, | ||
command: () => command, | ||
description: () => description, | ||
handler: () => handler | ||
}); | ||
module.exports = __toCommonJS(check_exports); | ||
var import_cli_helpers = require("@redwoodjs/cli-helpers"); | ||
var import_lib = require("../lib"); | ||
var import_colors = __toESM(require("../lib/colors")); | ||
const command = "check"; | ||
const aliases = ["diagnostics"]; | ||
const description = "Get structural diagnostics for a Redwood project (experimental)"; | ||
const handler = () => { | ||
(0, import_cli_helpers.recordTelemetryAttributes)({ | ||
command: "check" | ||
}); | ||
const { | ||
printDiagnostics, | ||
DiagnosticSeverity | ||
} = require("@redwoodjs/structure"); | ||
printDiagnostics((0, import_lib.getPaths)().base, { | ||
getSeverityLabel: (severity) => { | ||
if (severity === DiagnosticSeverity.Error) { | ||
return import_colors.default.error("error"); | ||
} | ||
if (severity === DiagnosticSeverity.Warning) { | ||
return import_colors.default.warning("warning"); | ||
} | ||
return import_colors.default.info("info"); | ||
} | ||
}); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
aliases, | ||
command, | ||
description, | ||
handler | ||
}); |
Oops, something went wrong.