@lsst/pik 0.6.4 → 0.6.5
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/dist/lib/program.d.ts.map +1 -1
- package/dist/lib/program.js +43 -3
- package/dist/lib/program.spec.js +1 -1
- package/package.json +9 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAmDxB,eAAO,MAAM,OAAO,SAGG,CAAC;AA0CxB;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAsE9D"}
|
package/dist/lib/program.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { select, Separator } from '@inquirer/prompts';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
|
-
import {
|
|
4
|
+
import { writeFileSync } from 'fs';
|
|
5
|
+
import { resolve } from 'path';
|
|
6
|
+
import { loadConfig, findLocalConfig, isValidPlugin, } from '@lsst/pik-core';
|
|
5
7
|
import { selectPlugin } from '@lsst/pik-plugin-select';
|
|
6
8
|
import { worktreePlugin } from '@lsst/pik-plugin-worktree';
|
|
7
9
|
import { killportPlugin } from './plugins/killport.js';
|
|
8
10
|
import pkg from '../../package.json' with { type: 'json' };
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
const builtinPlugins = [
|
|
12
|
+
selectPlugin,
|
|
13
|
+
worktreePlugin,
|
|
14
|
+
killportPlugin,
|
|
15
|
+
];
|
|
11
16
|
/**
|
|
12
17
|
* Get plugins that are enabled in the config.
|
|
13
18
|
* - Built-in plugins are enabled if their command key exists in config
|
|
@@ -44,6 +49,41 @@ export const program = new Command()
|
|
|
44
49
|
.name(pkg.name)
|
|
45
50
|
.description(pkg.description)
|
|
46
51
|
.version(pkg.version);
|
|
52
|
+
const DEFAULT_CONFIG = `export default {
|
|
53
|
+
// Select plugin - switch between options in files
|
|
54
|
+
select: {
|
|
55
|
+
include: ['.env*'], // Files to scan for @pik markers
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Worktree plugin - manage git worktrees
|
|
59
|
+
// worktree: {
|
|
60
|
+
// baseDir: '../', // Where to create worktrees (relative to repo root)
|
|
61
|
+
// copyFiles: ['.env', '.npmrc'], // Files to copy to new worktrees
|
|
62
|
+
// postCreate: 'npm install', // Command to run after creating worktree
|
|
63
|
+
// },
|
|
64
|
+
|
|
65
|
+
// Killport plugin - kill processes on specific ports
|
|
66
|
+
// killport: {
|
|
67
|
+
// defaultPort: 3000, // Default port number for interactive prompt
|
|
68
|
+
// },
|
|
69
|
+
};
|
|
70
|
+
`;
|
|
71
|
+
program
|
|
72
|
+
.command('init')
|
|
73
|
+
.description('Create a default pik config file')
|
|
74
|
+
.action(async () => {
|
|
75
|
+
const cwd = process.cwd();
|
|
76
|
+
const fileName = 'pik.config.mjs';
|
|
77
|
+
const configPath = resolve(cwd, fileName);
|
|
78
|
+
const existingConfig = await findLocalConfig(cwd);
|
|
79
|
+
if (existingConfig) {
|
|
80
|
+
console.log(pc.yellow(`Config file already exists: ${existingConfig}`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
writeFileSync(configPath, DEFAULT_CONFIG, 'utf-8');
|
|
84
|
+
console.log(pc.green('✓') + ' Created ' + pc.bold(fileName));
|
|
85
|
+
console.log(pc.dim('Edit the config file to enable plugins'));
|
|
86
|
+
});
|
|
47
87
|
/**
|
|
48
88
|
* Initialize the program by loading config and registering enabled plugins.
|
|
49
89
|
*/
|
package/dist/lib/program.spec.js
CHANGED
|
@@ -111,7 +111,7 @@ describe('program', () => {
|
|
|
111
111
|
expect(registerFn).toHaveBeenCalledWith(expect.any(Command));
|
|
112
112
|
});
|
|
113
113
|
it('should skip invalid plugins and log error', async () => {
|
|
114
|
-
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() =>
|
|
114
|
+
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
115
115
|
const invalidPlugin = {
|
|
116
116
|
name: 'Invalid',
|
|
117
117
|
// missing description, command, register
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lsst/pik",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "CLI
|
|
3
|
+
"version": "0.6.5",
|
|
4
|
+
"description": "Extensible CLI toolkit for simplifying developers' everyday tasks like config switching and worktree management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Yurii Tatar <lsst25@gmail.com>",
|
|
@@ -11,13 +11,19 @@
|
|
|
11
11
|
"directory": "packages/cli"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
|
+
"toolkit",
|
|
14
15
|
"cli",
|
|
16
|
+
"plugin",
|
|
15
17
|
"config",
|
|
16
18
|
"configuration",
|
|
17
19
|
"switch",
|
|
18
20
|
"toggle",
|
|
19
21
|
"environment",
|
|
20
|
-
"env"
|
|
22
|
+
"env",
|
|
23
|
+
"worktree",
|
|
24
|
+
"git",
|
|
25
|
+
"developer-tools",
|
|
26
|
+
"monorepo"
|
|
21
27
|
],
|
|
22
28
|
"bin": {
|
|
23
29
|
"pik": "./dist/bin/pik.js"
|