create-rigorail 0.0.0-stage → 0.1.1
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 +15 -2
- package/index.mjs +204 -0
- package/package.json +38 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmed Tolan
|
|
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
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-rigorail
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a new [Rigorail](https://github.com/ahmedtolan2019/rigorail) project:
|
|
4
|
+
vibe coding with engineered React frontends.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm create rigorail@latest my-app
|
|
8
|
+
cd my-app
|
|
9
|
+
npm install
|
|
10
|
+
npm run dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Options (after `--`): `--ref <branch|tag>` picks a template version, `--install`
|
|
14
|
+
runs `npm install`, `--no-git` skips the initial commit.
|
|
15
|
+
|
|
16
|
+
MIT © Ahmed Tolan
|
package/index.mjs
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Creates a new project from the Rigorail template:
|
|
3
|
+
// npm create rigorail@latest my-app
|
|
4
|
+
// Downloads the template from GitHub, renames the package, initializes git and
|
|
5
|
+
// prints the next steps. No dependencies: Node 20+ with fetch and the system tar.
|
|
6
|
+
import { spawnSync } from 'node:child_process'
|
|
7
|
+
import {
|
|
8
|
+
existsSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readdirSync,
|
|
11
|
+
readFileSync,
|
|
12
|
+
realpathSync,
|
|
13
|
+
rmSync,
|
|
14
|
+
writeFileSync,
|
|
15
|
+
} from 'node:fs'
|
|
16
|
+
import { tmpdir } from 'node:os'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
import { createInterface } from 'node:readline/promises'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
20
|
+
|
|
21
|
+
export const REPOSITORY = 'ahmedtolan2019/rigorail'
|
|
22
|
+
const HELP = `Usage: npm create rigorail@latest [directory] [-- options]
|
|
23
|
+
|
|
24
|
+
Options:
|
|
25
|
+
--ref <branch|tag> Template version to use (default: main)
|
|
26
|
+
--install Run npm install after creating the project
|
|
27
|
+
--no-git Do not initialize a git repository
|
|
28
|
+
-h, --help Show this help`
|
|
29
|
+
|
|
30
|
+
/** Parses CLI arguments into { directory, ref, install, git, help }. */
|
|
31
|
+
export function parseArgs(argv) {
|
|
32
|
+
const options = {
|
|
33
|
+
directory: '',
|
|
34
|
+
ref: 'main',
|
|
35
|
+
install: false,
|
|
36
|
+
git: true,
|
|
37
|
+
help: false,
|
|
38
|
+
}
|
|
39
|
+
for (let index = 0; index < argv.length; index++) {
|
|
40
|
+
const arg = argv[index]
|
|
41
|
+
if (arg === '-h' || arg === '--help') options.help = true
|
|
42
|
+
else if (arg === '--install') options.install = true
|
|
43
|
+
else if (arg === '--no-git') options.git = false
|
|
44
|
+
else if (arg === '--ref') options.ref = argv[++index] ?? ''
|
|
45
|
+
else if (arg.startsWith('--ref=')) options.ref = arg.slice(6)
|
|
46
|
+
else if (arg.startsWith('-')) throw new Error(`Unknown option: ${arg}`)
|
|
47
|
+
else if (!options.directory) options.directory = arg
|
|
48
|
+
else throw new Error(`Unexpected argument: ${arg}`)
|
|
49
|
+
}
|
|
50
|
+
if (!options.ref) throw new Error('--ref needs a branch or tag name.')
|
|
51
|
+
return options
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** npm package names: lowercase, URL-safe, no leading dot or underscore. */
|
|
55
|
+
export function toPackageName(directory) {
|
|
56
|
+
const name = path
|
|
57
|
+
.basename(path.resolve(directory))
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
60
|
+
.replace(/^[._-]+|[-]+$/g, '')
|
|
61
|
+
return name || 'my-app'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Turns the template's package.json into the new project's own manifest. */
|
|
65
|
+
export function personalizePackage(manifest, name) {
|
|
66
|
+
const next = { ...manifest, name, version: '0.1.0', private: true }
|
|
67
|
+
for (const key of [
|
|
68
|
+
'description',
|
|
69
|
+
'author',
|
|
70
|
+
'homepage',
|
|
71
|
+
'repository',
|
|
72
|
+
'bugs',
|
|
73
|
+
'keywords',
|
|
74
|
+
])
|
|
75
|
+
delete next[key]
|
|
76
|
+
// The initializer is removed from new projects, so drop its test from the gate.
|
|
77
|
+
if (next.scripts)
|
|
78
|
+
next.scripts = Object.fromEntries(
|
|
79
|
+
Object.entries(next.scripts).map(([key, value]) => [
|
|
80
|
+
key,
|
|
81
|
+
value.replace(/\s+packages\/create-rigorail\/\S+/g, ''),
|
|
82
|
+
]),
|
|
83
|
+
)
|
|
84
|
+
return next
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Template-maintainer files that would point a new project at the Rigorail repo. */
|
|
88
|
+
export const MAINTAINER_FILES = [
|
|
89
|
+
'packages/create-rigorail',
|
|
90
|
+
'.github/workflows/publish-create.yml',
|
|
91
|
+
'.github/FUNDING.yml',
|
|
92
|
+
'.github/ISSUE_TEMPLATE/config.yml',
|
|
93
|
+
'SECURITY.md',
|
|
94
|
+
'CODE_OF_CONDUCT.md',
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
async function askDirectory() {
|
|
98
|
+
const prompt = createInterface({
|
|
99
|
+
input: process.stdin,
|
|
100
|
+
output: process.stdout,
|
|
101
|
+
})
|
|
102
|
+
const answer = await prompt.question('Project directory (my-app): ')
|
|
103
|
+
prompt.close()
|
|
104
|
+
return answer.trim() || 'my-app'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function run(command, args, cwd) {
|
|
108
|
+
const result = spawnSync(command, args, {
|
|
109
|
+
cwd,
|
|
110
|
+
stdio: 'inherit',
|
|
111
|
+
shell: process.platform === 'win32',
|
|
112
|
+
})
|
|
113
|
+
return result.status === 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function main() {
|
|
117
|
+
const options = parseArgs(process.argv.slice(2))
|
|
118
|
+
if (options.help) {
|
|
119
|
+
console.log(HELP)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
const directory = options.directory || (await askDirectory())
|
|
123
|
+
const target = path.resolve(directory)
|
|
124
|
+
if (existsSync(target) && readdirSync(target).length)
|
|
125
|
+
throw new Error(
|
|
126
|
+
`${directory} is not empty. Choose a new or empty directory.`,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
// RIGORAIL_ARCHIVE points at a local .tar.gz (testing or offline mirrors).
|
|
130
|
+
const local = process.env.RIGORAIL_ARCHIVE
|
|
131
|
+
const archive = local ?? path.join(tmpdir(), `rigorail-${process.pid}.tar.gz`)
|
|
132
|
+
if (!local) {
|
|
133
|
+
const url = `https://codeload.github.com/${REPOSITORY}/tar.gz/${encodeURIComponent(options.ref)}`
|
|
134
|
+
console.log(`Downloading Rigorail (${options.ref})...`)
|
|
135
|
+
const response = await fetch(url)
|
|
136
|
+
if (!response.ok)
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Download failed (${response.status}). Check --ref and your connection.`,
|
|
139
|
+
)
|
|
140
|
+
writeFileSync(archive, Buffer.from(await response.arrayBuffer()))
|
|
141
|
+
}
|
|
142
|
+
mkdirSync(target, { recursive: true })
|
|
143
|
+
try {
|
|
144
|
+
if (!run('tar', ['-xzf', archive, '-C', target, '--strip-components=1']))
|
|
145
|
+
throw new Error('Could not extract the template. Is tar available?')
|
|
146
|
+
} finally {
|
|
147
|
+
if (!local) rmSync(archive, { force: true })
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Maintainer-only files (initializer, sponsor button, publish workflow...) belong
|
|
151
|
+
// to the template, not to the new project.
|
|
152
|
+
for (const file of MAINTAINER_FILES)
|
|
153
|
+
rmSync(path.join(target, file), { recursive: true, force: true })
|
|
154
|
+
if (
|
|
155
|
+
existsSync(path.join(target, 'packages')) &&
|
|
156
|
+
!readdirSync(path.join(target, 'packages')).length
|
|
157
|
+
)
|
|
158
|
+
rmSync(path.join(target, 'packages'), { recursive: true, force: true })
|
|
159
|
+
const manifestPath = path.join(target, 'package.json')
|
|
160
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
161
|
+
writeFileSync(
|
|
162
|
+
manifestPath,
|
|
163
|
+
JSON.stringify(
|
|
164
|
+
personalizePackage(manifest, toPackageName(directory)),
|
|
165
|
+
null,
|
|
166
|
+
2,
|
|
167
|
+
) + '\n',
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if (options.git && run('git', ['init', '-q'], target)) {
|
|
171
|
+
run('git', ['add', '-A'], target)
|
|
172
|
+
run(
|
|
173
|
+
'git',
|
|
174
|
+
['commit', '-q', '-m', 'chore: start from the Rigorail template'],
|
|
175
|
+
target,
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
if (options.install) run('npm', ['install'], target)
|
|
179
|
+
|
|
180
|
+
const relative = path.relative(process.cwd(), target) || '.'
|
|
181
|
+
const cd = /\s/.test(relative) ? `"${relative}"` : relative
|
|
182
|
+
console.log(`
|
|
183
|
+
Created ${relative}.
|
|
184
|
+
|
|
185
|
+
Next steps:
|
|
186
|
+
cd ${cd}
|
|
187
|
+
${options.install ? '' : 'npm install\n '}npm run dev # http://localhost:5173, demo data, no backend needed
|
|
188
|
+
|
|
189
|
+
Then open it with your coding agent and start with:
|
|
190
|
+
"Read AGENTS.md, run npm run check, and summarize how this project is organized."
|
|
191
|
+
Prompts for common tasks: README.md#prompts-for-your-agent`)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// npm runs bins through a node_modules/.bin symlink, so compare real paths.
|
|
195
|
+
const isEntryPoint = (scriptPath) =>
|
|
196
|
+
Boolean(scriptPath) &&
|
|
197
|
+
existsSync(scriptPath) &&
|
|
198
|
+
realpathSync(scriptPath) === realpathSync(fileURLToPath(import.meta.url))
|
|
199
|
+
|
|
200
|
+
if (isEntryPoint(process.argv[1]))
|
|
201
|
+
main().catch((error) => {
|
|
202
|
+
console.error(`\n${error instanceof Error ? error.message : error}`)
|
|
203
|
+
process.exitCode = 1
|
|
204
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rigorail",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Create a Rigorail project: vibe coding with engineered React frontends for developers and AI coding agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-rigorail": "index.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.mjs",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"rigorail",
|
|
19
|
+
"create-rigorail",
|
|
20
|
+
"react",
|
|
21
|
+
"typescript",
|
|
22
|
+
"vite",
|
|
23
|
+
"frontend-template",
|
|
24
|
+
"ai-agents",
|
|
25
|
+
"vibe-coding",
|
|
26
|
+
"enterprise",
|
|
27
|
+
"rtl"
|
|
28
|
+
],
|
|
29
|
+
"author": "Ahmed Tolan",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"homepage": "https://github.com/ahmedtolan2019/rigorail#readme",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/ahmedtolan2019/rigorail.git",
|
|
35
|
+
"directory": "packages/create-rigorail"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/ahmedtolan2019/rigorail/issues"
|
|
39
|
+
}
|
|
40
|
+
}
|