create-river-build-app
Advanced tools
Comparing version 0.0.112 to 0.0.113
@@ -329,4 +329,4 @@ "use strict"; | ||
isexe.sync = sync; | ||
var fs = require("fs"); | ||
function checkPathExt(path4, options) { | ||
var fs2 = require("fs"); | ||
function checkPathExt(path5, options) { | ||
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT; | ||
@@ -342,3 +342,3 @@ if (!pathext) { | ||
var p = pathext[i].toLowerCase(); | ||
if (p && path4.substr(-p.length).toLowerCase() === p) { | ||
if (p && path5.substr(-p.length).toLowerCase() === p) { | ||
return true; | ||
@@ -349,15 +349,15 @@ } | ||
} | ||
function checkStat(stat, path4, options) { | ||
function checkStat(stat, path5, options) { | ||
if (!stat.isSymbolicLink() && !stat.isFile()) { | ||
return false; | ||
} | ||
return checkPathExt(path4, options); | ||
return checkPathExt(path5, options); | ||
} | ||
function isexe(path4, options, cb) { | ||
fs.stat(path4, function(er, stat) { | ||
cb(er, er ? false : checkStat(stat, path4, options)); | ||
function isexe(path5, options, cb) { | ||
fs2.stat(path5, function(er, stat) { | ||
cb(er, er ? false : checkStat(stat, path5, options)); | ||
}); | ||
} | ||
function sync(path4, options) { | ||
return checkStat(fs.statSync(path4), path4, options); | ||
function sync(path5, options) { | ||
return checkStat(fs2.statSync(path5), path5, options); | ||
} | ||
@@ -373,10 +373,10 @@ } | ||
isexe.sync = sync; | ||
var fs = require("fs"); | ||
function isexe(path4, options, cb) { | ||
fs.stat(path4, function(er, stat) { | ||
var fs2 = require("fs"); | ||
function isexe(path5, options, cb) { | ||
fs2.stat(path5, function(er, stat) { | ||
cb(er, er ? false : checkStat(stat, options)); | ||
}); | ||
} | ||
function sync(path4, options) { | ||
return checkStat(fs.statSync(path4), options); | ||
function sync(path5, options) { | ||
return checkStat(fs2.statSync(path5), options); | ||
} | ||
@@ -406,3 +406,3 @@ function checkStat(stat, options) { | ||
"use strict"; | ||
var fs = require("fs"); | ||
var fs2 = require("fs"); | ||
var core; | ||
@@ -416,3 +416,3 @@ if (process.platform === "win32" || global.TESTING_WINDOWS) { | ||
isexe.sync = sync; | ||
function isexe(path4, options, cb) { | ||
function isexe(path5, options, cb) { | ||
if (typeof options === "function") { | ||
@@ -427,3 +427,3 @@ cb = options; | ||
return new Promise(function(resolve, reject) { | ||
isexe(path4, options || {}, function(er, is) { | ||
isexe(path5, options || {}, function(er, is) { | ||
if (er) { | ||
@@ -437,3 +437,3 @@ reject(er); | ||
} | ||
core(path4, options || {}, function(er, is) { | ||
core(path5, options || {}, function(er, is) { | ||
if (er) { | ||
@@ -448,5 +448,5 @@ if (er.code === "EACCES" || options && options.ignoreErrors) { | ||
} | ||
function sync(path4, options) { | ||
function sync(path5, options) { | ||
try { | ||
return core.sync(path4, options || {}); | ||
return core.sync(path5, options || {}); | ||
} catch (er) { | ||
@@ -468,3 +468,3 @@ if (options && options.ignoreErrors || er.code === "EACCES") { | ||
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; | ||
var path4 = require("path"); | ||
var path5 = require("path"); | ||
var COLON = isWindows ? ";" : ":"; | ||
@@ -507,3 +507,3 @@ var isexe = require_isexe(); | ||
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; | ||
const pCmd = path4.join(pathPart, cmd); | ||
const pCmd = path5.join(pathPart, cmd); | ||
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; | ||
@@ -535,3 +535,3 @@ resolve(subStep(p, i, 0)); | ||
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; | ||
const pCmd = path4.join(pathPart, cmd); | ||
const pCmd = path5.join(pathPart, cmd); | ||
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; | ||
@@ -584,3 +584,3 @@ for (let j = 0; j < pathExt.length; j++) { | ||
"use strict"; | ||
var path4 = require("path"); | ||
var path5 = require("path"); | ||
var which = require_which(); | ||
@@ -603,3 +603,3 @@ var getPathKey = require_path_key(); | ||
path: env[getPathKey({ env })], | ||
pathExt: withoutPathExt ? path4.delimiter : void 0 | ||
pathExt: withoutPathExt ? path5.delimiter : void 0 | ||
}); | ||
@@ -613,3 +613,3 @@ } catch (e) { | ||
if (resolved) { | ||
resolved = path4.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved); | ||
resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved); | ||
} | ||
@@ -668,4 +668,4 @@ return resolved; | ||
} | ||
const [path4, argument] = match[0].replace(/#! ?/, "").split(" "); | ||
const binary = path4.split("/").pop(); | ||
const [path5, argument] = match[0].replace(/#! ?/, "").split(" "); | ||
const binary = path5.split("/").pop(); | ||
if (binary === "env") { | ||
@@ -683,3 +683,3 @@ return argument; | ||
"use strict"; | ||
var fs = require("fs"); | ||
var fs2 = require("fs"); | ||
var shebangCommand = require_shebang_command(); | ||
@@ -691,5 +691,5 @@ function readShebang(command) { | ||
try { | ||
fd = fs.openSync(command, "r"); | ||
fs.readSync(fd, buffer, 0, size, 0); | ||
fs.closeSync(fd); | ||
fd = fs2.openSync(command, "r"); | ||
fs2.readSync(fd, buffer, 0, size, 0); | ||
fs2.closeSync(fd); | ||
} catch (e) { | ||
@@ -707,3 +707,3 @@ } | ||
"use strict"; | ||
var path4 = require("path"); | ||
var path5 = require("path"); | ||
var resolveCommand = require_resolveCommand(); | ||
@@ -733,3 +733,3 @@ var escape = require_escape(); | ||
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile); | ||
parsed.command = path4.normalize(parsed.command); | ||
parsed.command = path5.normalize(parsed.command); | ||
parsed.command = escape.command(parsed.command); | ||
@@ -744,3 +744,3 @@ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars)); | ||
} | ||
function parse(command, args, options) { | ||
function parse2(command, args, options) { | ||
if (args && !Array.isArray(args)) { | ||
@@ -764,3 +764,3 @@ options = args; | ||
} | ||
module2.exports = parse; | ||
module2.exports = parse2; | ||
} | ||
@@ -824,6 +824,6 @@ }); | ||
var cp = require("child_process"); | ||
var parse = require_parse(); | ||
var parse2 = require_parse(); | ||
var enoent = require_enoent(); | ||
function spawn2(command, args, options) { | ||
const parsed = parse(command, args, options); | ||
function spawn3(command, args, options) { | ||
const parsed = parse2(command, args, options); | ||
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options); | ||
@@ -834,3 +834,3 @@ enoent.hookChildProcess(spawned, parsed); | ||
function spawnSync(command, args, options) { | ||
const parsed = parse(command, args, options); | ||
const parsed = parse2(command, args, options); | ||
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options); | ||
@@ -840,6 +840,6 @@ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); | ||
} | ||
module2.exports = spawn2; | ||
module2.exports.spawn = spawn2; | ||
module2.exports = spawn3; | ||
module2.exports.spawn = spawn3; | ||
module2.exports.sync = spawnSync; | ||
module2.exports._parse = parse; | ||
module2.exports._parse = parse2; | ||
module2.exports._enoent = enoent; | ||
@@ -851,4 +851,4 @@ } | ||
var import_minimist = __toESM(require_minimist()); | ||
var import_node_path3 = __toESM(require("path")); | ||
var import_picocolors2 = __toESM(require_picocolors()); | ||
var import_node_path4 = __toESM(require("path")); | ||
var import_picocolors3 = __toESM(require_picocolors()); | ||
@@ -868,6 +868,6 @@ // src/utils.ts | ||
}; | ||
var addDependencies = async (cfg) => { | ||
const { projectDir, dependencies, devDependencies } = cfg; | ||
var addDependencies = async (projectDir, cfg) => { | ||
const packageJsonPath = import_node_path.default.join(projectDir, "package.json"); | ||
const packageJson = JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf8")); | ||
const { dependencies, devDependencies } = cfg(packageJson); | ||
if (devDependencies && devDependencies.length > 0) { | ||
@@ -878,3 +878,7 @@ if (!packageJson.devDependencies) { | ||
for (const dep of devDependencies) { | ||
packageJson.devDependencies[dep] = "latest"; | ||
if (Array.isArray(dep)) { | ||
packageJson.devDependencies[dep[0]] = dep[1]; | ||
} else { | ||
packageJson.devDependencies[dep] = "latest"; | ||
} | ||
} | ||
@@ -886,3 +890,7 @@ } | ||
for (const dep of dependencies) { | ||
packageJson.dependencies[dep] = "latest"; | ||
if (Array.isArray(dep)) { | ||
packageJson.dependencies[dep[0]] = dep[1]; | ||
} else { | ||
packageJson.dependencies[dep] = "latest"; | ||
} | ||
} | ||
@@ -893,3 +901,3 @@ (0, import_node_fs.writeFileSync)(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n"); | ||
// src/modules/react.ts | ||
// src/modules/vite-react.ts | ||
var import_cross_spawn = __toESM(require_cross_spawn()); | ||
@@ -911,7 +919,6 @@ var import_node_path2 = __toESM(require("path")); | ||
console.log(import_picocolors.default.blue("\nAdding River SDK dependencies...")); | ||
await addDependencies({ | ||
projectDir: cfg.projectDir, | ||
await addDependencies(cfg.projectDir, () => ({ | ||
dependencies: ["@river-build/react-sdk", "@river-build/sdk"], | ||
devDependencies: ["vite-plugin-node-polyfills"] | ||
}); | ||
})); | ||
console.log(import_picocolors.default.green("\nRiver SDK dependencies added successfully.")); | ||
@@ -923,3 +930,3 @@ console.log(import_picocolors.default.blue("\nUpdating vite.config.ts...")); | ||
var scaffoldViteReactApp = async (cfg) => { | ||
const { targetDir, packageName, viteTemplate } = cfg; | ||
const { targetDir, packageName, viteTemplate = "react-ts" } = cfg; | ||
const pkgManager = getPackageManager(); | ||
@@ -964,5 +971,109 @@ const createViteCommand = (() => { | ||
// src/modules/clone-playground.ts | ||
var import_cross_spawn2 = __toESM(require_cross_spawn()); | ||
var import_node_path3 = __toESM(require("path")); | ||
var import_picocolors2 = __toESM(require_picocolors()); | ||
var import_node_fs3 = __toESM(require("fs")); | ||
var jsoncParser = __toESM(require("jsonc-parser")); | ||
var clonePlayground = async (cfg) => { | ||
console.log(import_picocolors2.default.blue("\nCloning River Build Playground...")); | ||
const result = await cloneRepo(cfg); | ||
if (result?.signal === "SIGINT" || result?.signal === "SIGTERM") { | ||
console.log("\nOperation cancelled"); | ||
process.exit(1); | ||
} | ||
if (result && result.status !== 0) { | ||
console.error(import_picocolors2.default.red("\nFailed to clone playground.")); | ||
process.exit(1); | ||
} | ||
console.log(import_picocolors2.default.green("\nPlayground cloned successfully.")); | ||
console.log(import_picocolors2.default.blue("\nUpdating dependencies...")); | ||
await updateDependencies(cfg); | ||
console.log(import_picocolors2.default.green("\nDependencies updated successfully.")); | ||
await fixTsConfig(cfg); | ||
import_cross_spawn2.default.sync("git", ["init"], { | ||
stdio: "inherit", | ||
cwd: cfg.targetDir | ||
}); | ||
}; | ||
var cloneRepo = async (cfg) => { | ||
const { targetDir } = cfg; | ||
const tempDir = `${targetDir}-temp`; | ||
const cloneResult = import_cross_spawn2.default.sync( | ||
"git", | ||
[ | ||
"clone", | ||
"--no-checkout", | ||
"--depth", | ||
"1", | ||
"--sparse", | ||
"https://github.com/river-build/river.git", | ||
tempDir | ||
], | ||
{ stdio: "inherit" } | ||
); | ||
if (cloneResult.status !== 0) return cloneResult; | ||
const sparseResult = import_cross_spawn2.default.sync("git", ["sparse-checkout", "set", "packages/playground"], { | ||
stdio: "inherit", | ||
cwd: tempDir | ||
}); | ||
if (sparseResult.status !== 0) return sparseResult; | ||
const checkoutResult = import_cross_spawn2.default.sync("git", ["checkout"], { | ||
stdio: "inherit", | ||
cwd: tempDir | ||
}); | ||
if (checkoutResult.status !== 0) return checkoutResult; | ||
const playgroundDir = import_node_path3.default.join(tempDir, "packages/playground"); | ||
const baseTsConfigPath = import_node_path3.default.join(tempDir, "packages/tsconfig.base.json"); | ||
if (!import_node_fs3.default.existsSync(playgroundDir)) { | ||
console.error(import_picocolors2.default.red(` | ||
Playground directory not found at ${playgroundDir}`)); | ||
return; | ||
} | ||
import_node_fs3.default.mkdirSync(targetDir, { recursive: true }); | ||
import_node_fs3.default.cpSync(playgroundDir, targetDir, { recursive: true }); | ||
if (import_node_fs3.default.existsSync(baseTsConfigPath)) { | ||
import_node_fs3.default.copyFileSync(baseTsConfigPath, import_node_path3.default.join(targetDir, "tsconfig.base.json")); | ||
} | ||
import_node_fs3.default.rmSync(tempDir, { recursive: true, force: true }); | ||
return; | ||
}; | ||
var updateDependencies = async (cfg) => { | ||
const { projectDir } = cfg; | ||
await addDependencies(projectDir, (json) => { | ||
const allRiverBuildDeps = Object.keys(json.dependencies).filter( | ||
(dep) => dep.startsWith("@river-build") | ||
); | ||
const allRiverBuildDevDeps = Object.keys(json.devDependencies).filter( | ||
(dep) => dep.startsWith("@river-build") | ||
); | ||
return { | ||
dependencies: [...allRiverBuildDeps, ["@wagmi/core", json.dependencies.wagmi]], | ||
devDependencies: [ | ||
...allRiverBuildDevDeps, | ||
// hardcoded for now. ^5.1.6 will make npm install to get the latest 5.x.x | ||
["typescript", "5.1.6"] | ||
] | ||
}; | ||
}); | ||
}; | ||
var fixTsConfig = async (cfg) => { | ||
const { projectDir } = cfg; | ||
const tsConfigPath = import_node_path3.default.join(projectDir, "tsconfig.json"); | ||
if (import_node_fs3.default.existsSync(tsConfigPath)) { | ||
const tsConfigContent = import_node_fs3.default.readFileSync(tsConfigPath, "utf8"); | ||
const tsConfig = jsoncParser.parse(tsConfigContent); | ||
if (tsConfig.extends === "./../tsconfig.base.json") { | ||
const edits = jsoncParser.modify(tsConfigContent, ["extends"], "./tsconfig.base.json", { | ||
formattingOptions: { tabSize: 2 } | ||
}); | ||
const updatedContent = jsoncParser.applyEdits(tsConfigContent, edits); | ||
import_node_fs3.default.writeFileSync(tsConfigPath, updatedContent); | ||
} | ||
} | ||
}; | ||
// src/index.ts | ||
var argv = (0, import_minimist.default)(process.argv.slice(2), { | ||
default: { help: false, template: "react-ts" }, | ||
default: { help: false, template: "playground" }, | ||
alias: { h: "help", t: "template" }, | ||
@@ -980,15 +1091,15 @@ string: ["_"] | ||
Available templates: | ||
${import_picocolors2.default.yellow("react-ts react")} | ||
${import_picocolors3.default.yellow("react-ts react playground")} | ||
`; | ||
var build = { | ||
"react-ts": buildRiverReactApp, | ||
react: buildRiverReactApp | ||
// if you need a new template, add it here | ||
react: buildRiverReactApp, | ||
playground: clonePlayground | ||
}; | ||
async function init() { | ||
const targetDir = formatTargetDir(argv._[0]) || "."; | ||
const packageName = targetDir === "." ? import_node_path3.default.basename(process.cwd()) : targetDir; | ||
const projectDir = targetDir === "." ? process.cwd() : import_node_path3.default.join(process.cwd(), targetDir); | ||
const packageName = targetDir === "." ? import_node_path4.default.basename(process.cwd()) : targetDir; | ||
const projectDir = targetDir === "." ? process.cwd() : import_node_path4.default.join(process.cwd(), targetDir); | ||
const pkgManager = getPackageManager(); | ||
const template = (argv.template || argv.t) ?? "react-ts"; | ||
const template = argv.template || argv.t; | ||
const help = argv.help; | ||
@@ -999,3 +1110,3 @@ if (help) { | ||
} | ||
console.log(import_picocolors2.default.blue(` | ||
console.log(import_picocolors3.default.blue(` | ||
Scaffolding project in ${packageName}...`)); | ||
@@ -1006,7 +1117,7 @@ await build[template]({ | ||
targetDir, | ||
viteTemplate: template | ||
viteTemplate: template !== "playground" ? template : void 0 | ||
}); | ||
console.log(import_picocolors2.default.green("\nDone! \u{1F389}")); | ||
console.log(import_picocolors2.default.blue("\nNow run: cd " + targetDir + " && " + pkgManager + ` install`)); | ||
console.log(import_picocolors2.default.blue("\nThen run: " + pkgManager + " dev")); | ||
console.log(import_picocolors3.default.green("\nDone! \u{1F389}")); | ||
console.log(import_picocolors3.default.blue("\nNow run: cd " + targetDir + " && " + pkgManager + ` install`)); | ||
console.log(import_picocolors3.default.blue("\nThen run: " + pkgManager + " dev")); | ||
} | ||
@@ -1013,0 +1124,0 @@ init().catch((e) => { |
{ | ||
"name": "create-river-build-app", | ||
"version": "0.0.112", | ||
"version": "0.0.113", | ||
"bin": "index.js", | ||
@@ -13,2 +13,3 @@ "engines": { | ||
"scripts": { | ||
"watch": "tsup --watch", | ||
"build": "tsup" | ||
@@ -27,3 +28,6 @@ }, | ||
}, | ||
"gitHead": "c8486069c7474c19f7dfe0268fccc925f230f36c" | ||
"dependencies": { | ||
"jsonc-parser": "^3.3.1" | ||
}, | ||
"gitHead": "828542c10a7d1f5388bda7d134cdd84b589b9901" | ||
} |
@@ -5,4 +5,16 @@ # Create River Build App | ||
It will run `create-vite` to scaffold the project using `react-ts` template. | ||
## Templates | ||
### Playground Template | ||
By default, the script will create a new app using the Playground template: a full-featured example application. | ||
```bash | ||
yarn create river-build-app my-app | ||
``` | ||
### React Templates | ||
It will run `create-vite` to scaffold the project using either `react-ts` or `react` template. | ||
Then, it will install the necessary dependencies: `@river-build/sdk` and `@river-build/react-sdk`. | ||
@@ -12,2 +24,6 @@ | ||
```bash | ||
yarn create river-build-app my-app --template react-ts | ||
``` | ||
## Usage | ||
@@ -29,1 +45,13 @@ | ||
``` | ||
You can specify a template using the `-t` or `--template` flag: | ||
```bash | ||
yarn create river-build-app my-app --template react-ts | ||
``` | ||
Available templates: | ||
- playground (default) | ||
- react-ts | ||
- react |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212579
2143
55
1
31
+ Addedjsonc-parser@^3.3.1
+ Addedjsonc-parser@3.3.1(transitive)