create-ridu 0.1.0
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 +24 -0
- package/package.json +38 -0
- package/src/arguments.js +28 -0
- package/src/cli.js +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Haniel Ubogu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# `create-ridu`
|
|
2
|
+
|
|
3
|
+
Create a project with the native Ridu CLI from the same Ridu release:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create ridu@latest my-app
|
|
7
|
+
bun create ridu@latest my-app
|
|
8
|
+
pnpm create ridu@latest my-app
|
|
9
|
+
yarn create ridu my-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Omit `my-app` to choose the project directory inside the wizard.
|
|
13
|
+
|
|
14
|
+
The initializer detects npm, Bun, pnpm, or Yarn and records that choice in the generated
|
|
15
|
+
`ridu.toml`. Options after a launcher's argument separator are forwarded to `ridu new`:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm create ridu@latest -- --template blank --database sqlite my-app
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The initializer runs the matching `@riducms/cli` release. Generated projects retain that launcher
|
|
22
|
+
as an exact development dependency. After
|
|
23
|
+
creation, install and run scripts with the same package manager. For example, npm users run
|
|
24
|
+
`npm install`, `npm run dev`, and `npm run ridu -- <command>` without installing a global CLI.
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bin": {
|
|
3
|
+
"create-ridu": "./src/cli.js"
|
|
4
|
+
},
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/riducms/ridu/issues"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@riducms/cli": "0.1.0"
|
|
10
|
+
},
|
|
11
|
+
"description": "Create a Ridu project with the matching native Ridu CLI.",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src/arguments.js",
|
|
17
|
+
"src/cli.js",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://riducms.com",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"name": "create-ridu",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"provenance": true
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"directory": "packages/create-ridu",
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/riducms/ridu.git"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"check": "bun test",
|
|
34
|
+
"test": "bun test"
|
|
35
|
+
},
|
|
36
|
+
"type": "module",
|
|
37
|
+
"version": "0.1.0"
|
|
38
|
+
}
|
package/src/arguments.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const packageManagerNames = ["pnpm", "yarn", "bun", "npm"];
|
|
2
|
+
const packageManagers = new Set(packageManagerNames);
|
|
3
|
+
|
|
4
|
+
export function detectPackageManager(userAgent = "", executable = "") {
|
|
5
|
+
const name = userAgent.trim().split(/[\s/]/, 1)[0]?.toLowerCase();
|
|
6
|
+
if (packageManagers.has(name)) return name;
|
|
7
|
+
const executableName = executable.toLowerCase().split(/[\\/]/).at(-1) ?? "";
|
|
8
|
+
for (const manager of packageManagerNames) {
|
|
9
|
+
if (executableName.startsWith(manager)) return manager;
|
|
10
|
+
}
|
|
11
|
+
return "npm";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function initializerArguments(
|
|
15
|
+
arguments_,
|
|
16
|
+
userAgent = process.env.npm_config_user_agent ?? ""
|
|
17
|
+
) {
|
|
18
|
+
const hasExplicitManager = arguments_.some(
|
|
19
|
+
(argument) => argument === "--package-manager" || argument.startsWith("--package-manager=")
|
|
20
|
+
);
|
|
21
|
+
if (hasExplicitManager) return ["new", ...arguments_];
|
|
22
|
+
return [
|
|
23
|
+
"new",
|
|
24
|
+
"--package-manager",
|
|
25
|
+
detectPackageManager(userAgent, process.env.npm_execpath ?? process.execPath),
|
|
26
|
+
...arguments_,
|
|
27
|
+
];
|
|
28
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runRidu } from "@riducms/cli/run";
|
|
4
|
+
|
|
5
|
+
import { initializerArguments } from "./arguments.js";
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
process.exitCode = await runRidu(initializerArguments(process.argv.slice(2)));
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error(`create-ridu: ${error instanceof Error ? error.message : String(error)}`);
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
}
|