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