@crouton-kit/crouter 0.1.3 → 0.1.4
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/README.md +14 -1
- package/dist/cli.js +2 -0
- package/dist/core/bootstrap.d.ts +4 -0
- package/dist/core/bootstrap.js +70 -0
- package/dist/core/config.js +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,5 +9,18 @@ npm install -g @crouton-kit/crouter
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
crtr --help
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## Official marketplace
|
|
16
|
+
|
|
17
|
+
`crtr` ships with the [crouter official marketplace](https://github.com/crouton-labs/crouter-official-marketplace) pre-installed. On first run it is cloned into your user scope and registered automatically — no plugins are enabled by default.
|
|
18
|
+
|
|
19
|
+
Browse and install plugins from it:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
crtr marketplace browse crouter-official-marketplace
|
|
23
|
+
crtr marketplace install crouter-official-marketplace:<plugin>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To opt out of the bootstrap (e.g. in CI), set `CRTR_NO_BOOTSTRAP=1`.
|
package/dist/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ import { registerDoctorCommand } from './commands/doctor.js';
|
|
|
12
12
|
import { registerPlanCommand } from './commands/plan.js';
|
|
13
13
|
import { registerSpecCommand } from './commands/spec.js';
|
|
14
14
|
import { maybeAutoUpdate } from './core/auto-update.js';
|
|
15
|
+
import { ensureOfficialMarketplace } from './core/bootstrap.js';
|
|
15
16
|
function readPackageVersion() {
|
|
16
17
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
17
18
|
const pkgPath = join(here, '..', 'package.json');
|
|
@@ -33,6 +34,7 @@ registerUpdateCommand(program);
|
|
|
33
34
|
registerDoctorCommand(program);
|
|
34
35
|
registerPlanCommand(program);
|
|
35
36
|
registerSpecCommand(program);
|
|
37
|
+
ensureOfficialMarketplace(process.argv);
|
|
36
38
|
maybeAutoUpdate(process.argv);
|
|
37
39
|
program.parseAsync().catch((err) => {
|
|
38
40
|
process.stderr.write(`crtr: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const OFFICIAL_MARKETPLACE_NAME = "crouter-official-marketplace";
|
|
2
|
+
export declare const OFFICIAL_MARKETPLACE_URL = "https://github.com/crouton-labs/crouter-official-marketplace.git";
|
|
3
|
+
export declare const OFFICIAL_MARKETPLACE_REF = "main";
|
|
4
|
+
export declare function ensureOfficialMarketplace(argv: string[]): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { userScopeRoot } from './scope.js';
|
|
3
|
+
import { ensureDir, pathExists, removePath, nowIso } from './fs-utils.js';
|
|
4
|
+
import { readConfig, readState, updateConfig, updateState, ensureScopeInitialized } from './config.js';
|
|
5
|
+
import { clone } from './git.js';
|
|
6
|
+
import { readMarketplaceManifest } from './manifest.js';
|
|
7
|
+
export const OFFICIAL_MARKETPLACE_NAME = 'crouter-official-marketplace';
|
|
8
|
+
export const OFFICIAL_MARKETPLACE_URL = 'https://github.com/crouton-labs/crouter-official-marketplace.git';
|
|
9
|
+
export const OFFICIAL_MARKETPLACE_REF = 'main';
|
|
10
|
+
const SKIP_SUBCOMMANDS = new Set([
|
|
11
|
+
'help',
|
|
12
|
+
'--help',
|
|
13
|
+
'-h',
|
|
14
|
+
'--version',
|
|
15
|
+
'-v',
|
|
16
|
+
]);
|
|
17
|
+
function shouldSkipForArgv(argv) {
|
|
18
|
+
const sub = argv[2];
|
|
19
|
+
if (sub === undefined)
|
|
20
|
+
return true;
|
|
21
|
+
return SKIP_SUBCOMMANDS.has(sub);
|
|
22
|
+
}
|
|
23
|
+
export function ensureOfficialMarketplace(argv) {
|
|
24
|
+
try {
|
|
25
|
+
if (process.env.CRTR_NO_BOOTSTRAP === '1')
|
|
26
|
+
return;
|
|
27
|
+
if (shouldSkipForArgv(argv))
|
|
28
|
+
return;
|
|
29
|
+
const state = readState('user');
|
|
30
|
+
if (state.bootstrap_done === true)
|
|
31
|
+
return;
|
|
32
|
+
const cfg = readConfig('user');
|
|
33
|
+
if (cfg.marketplaces[OFFICIAL_MARKETPLACE_NAME] !== undefined) {
|
|
34
|
+
updateState('user', (s) => {
|
|
35
|
+
s.bootstrap_done = true;
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const root = userScopeRoot();
|
|
40
|
+
ensureScopeInitialized('user', root);
|
|
41
|
+
const mktsDir = join(root, 'marketplaces');
|
|
42
|
+
ensureDir(mktsDir);
|
|
43
|
+
const dest = join(mktsDir, OFFICIAL_MARKETPLACE_NAME);
|
|
44
|
+
if (pathExists(dest)) {
|
|
45
|
+
removePath(dest);
|
|
46
|
+
}
|
|
47
|
+
clone(OFFICIAL_MARKETPLACE_URL, dest, { depth: 1, ref: OFFICIAL_MARKETPLACE_REF });
|
|
48
|
+
const manifest = readMarketplaceManifest(dest);
|
|
49
|
+
if (manifest === null) {
|
|
50
|
+
removePath(dest);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
updateConfig('user', (c) => {
|
|
54
|
+
c.marketplaces[OFFICIAL_MARKETPLACE_NAME] = {
|
|
55
|
+
url: OFFICIAL_MARKETPLACE_URL,
|
|
56
|
+
ref: OFFICIAL_MARKETPLACE_REF,
|
|
57
|
+
installed_at: nowIso(),
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
updateState('user', (s) => {
|
|
61
|
+
s.bootstrap_done = true;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (process.env.CRTR_DEBUG === '1') {
|
|
66
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
67
|
+
process.stderr.write(`crtr: bootstrap error: ${msg}\n`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/core/config.js
CHANGED
|
@@ -36,6 +36,7 @@ export function readState(scope) {
|
|
|
36
36
|
marketplaces: existing.marketplaces ?? {},
|
|
37
37
|
plugins: existing.plugins ?? {},
|
|
38
38
|
last_self_check: existing.last_self_check,
|
|
39
|
+
bootstrap_done: existing.bootstrap_done,
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
export function writeConfig(scope, config) {
|
package/dist/types.d.ts
CHANGED