@houserules/create 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.
- package/LICENSE +21 -0
- package/README.md +25 -2
- package/bin/create-houserules.mjs +76 -0
- package/package.json +49 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Devin T. Currie
|
|
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,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @houserules/create
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The initializer for [`@houserules/cli`](https://www.npmjs.com/package/@houserules/cli). It adds
|
|
4
|
+
the cli to the repo's devDependencies with the package manager that invoked it and runs
|
|
5
|
+
`houserules init`. It holds no logic of its own beyond that.
|
|
6
|
+
|
|
7
|
+
`@houserules/cli` is the real package. Read its README for what houserules does and how to
|
|
8
|
+
configure it.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
In the repo to set up:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm create @houserules
|
|
16
|
+
pnpm create @houserules
|
|
17
|
+
yarn create @houserules
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Everything after the name goes to `init`, so `pnpm create @houserules --yes` skips the prompts
|
|
21
|
+
and `--dry-run` previews the writes. The install happens either way. After that, the binary is
|
|
22
|
+
local, and every later command is `pnpm houserules <cmd>` or `npx houserules <cmd>`.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The initializer behind `npm create @houserules`, `pnpm create @houserules`, and
|
|
4
|
+
* `yarn create @houserules`, run inside the repo to set up. It adds `@houserules/cli` to the
|
|
5
|
+
* repo's devDependencies with the package manager that invoked it, at the cli version this
|
|
6
|
+
* package was published with, then runs `houserules init` from the repo's own copy. Every
|
|
7
|
+
* argument is handed to `init`, so `--yes` and `--dry-run` work, and the install happens
|
|
8
|
+
* either way. The exit code is the package manager's when the install fails, and init's
|
|
9
|
+
* otherwise.
|
|
10
|
+
*/
|
|
11
|
+
import { spawnSync } from 'node:child_process';
|
|
12
|
+
import { existsSync } from 'node:fs';
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import { dirname, join } from 'node:path';
|
|
15
|
+
|
|
16
|
+
import pinnedCli from '@houserules/cli/package.json' with { type: 'json' };
|
|
17
|
+
|
|
18
|
+
const CLI = '@houserules/cli';
|
|
19
|
+
|
|
20
|
+
const INSTALL_ARGS = {
|
|
21
|
+
pnpm: ['add', '-D'],
|
|
22
|
+
yarn: ['add', '-D'],
|
|
23
|
+
bun: ['add', '-d'],
|
|
24
|
+
npm: ['install', '--save-dev'],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** The package manager that ran `create`, else the one whose lockfile the repo has, else npm. */
|
|
28
|
+
function packageManager(root) {
|
|
29
|
+
const agent = process.env.npm_config_user_agent ?? '';
|
|
30
|
+
const invoker = Object.keys(INSTALL_ARGS).find((name) =>
|
|
31
|
+
agent.startsWith(`${name}/`),
|
|
32
|
+
);
|
|
33
|
+
if (invoker) return invoker;
|
|
34
|
+
if (existsSync(join(root, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
35
|
+
if (existsSync(join(root, 'yarn.lock'))) return 'yarn';
|
|
36
|
+
if (existsSync(join(root, 'bun.lock')) || existsSync(join(root, 'bun.lockb')))
|
|
37
|
+
return 'bun';
|
|
38
|
+
return 'npm';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function run(command, args, cwd) {
|
|
42
|
+
return spawnSync(command, args, {
|
|
43
|
+
cwd,
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: process.platform === 'win32',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const root = process.cwd();
|
|
50
|
+
if (!existsSync(join(root, 'package.json'))) {
|
|
51
|
+
console.error(
|
|
52
|
+
`@houserules/create: no package.json in ${root}. Run \`npm init -y\` first, then run this again.`,
|
|
53
|
+
);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const manager = packageManager(root);
|
|
58
|
+
const install = run(
|
|
59
|
+
manager,
|
|
60
|
+
[...INSTALL_ARGS[manager], `${CLI}@^${pinnedCli.version}`],
|
|
61
|
+
root,
|
|
62
|
+
);
|
|
63
|
+
if (install.status !== 0) process.exit(install.status ?? 1);
|
|
64
|
+
|
|
65
|
+
const repoRequire = createRequire(join(root, 'package.json'));
|
|
66
|
+
const installedManifest = repoRequire.resolve(`${CLI}/package.json`);
|
|
67
|
+
const cliBin = join(
|
|
68
|
+
dirname(installedManifest),
|
|
69
|
+
repoRequire(installedManifest).bin.houserules,
|
|
70
|
+
);
|
|
71
|
+
const init = run(
|
|
72
|
+
process.execPath,
|
|
73
|
+
[cliBin, 'init', ...process.argv.slice(2)],
|
|
74
|
+
root,
|
|
75
|
+
);
|
|
76
|
+
process.exit(init.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@houserules/create",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Initializer for @houserules/cli: `npm create @houserules` adds the cli to the repo and runs init.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"create-houserules": "bin/create-houserules.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin"
|
|
14
|
+
],
|
|
15
|
+
"wireit": {
|
|
16
|
+
"build": {
|
|
17
|
+
"command": "publint",
|
|
18
|
+
"files": [
|
|
19
|
+
"package.json",
|
|
20
|
+
"bin/**"
|
|
21
|
+
],
|
|
22
|
+
"output": []
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/DTCurrie/houserules.git",
|
|
31
|
+
"directory": "packages/create"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/DTCurrie/houserules/tree/main/packages/create#readme",
|
|
34
|
+
"bugs": "https://github.com/DTCurrie/houserules/issues",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@houserules/cli": "^0.9.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"publint": "^0.3.25",
|
|
40
|
+
"wireit": "^0.14.13"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"author": "Devin T. Currie (https://github.com/DTCurrie)",
|
|
44
|
+
"keywords": [
|
|
45
|
+
"houserules",
|
|
46
|
+
"claude-code",
|
|
47
|
+
"create"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "wireit"
|
|
51
|
+
}
|
|
6
52
|
}
|