@codapult/cli 0.7.2 → 0.8.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/dist/commands/plugins.d.ts +5 -1
- package/dist/commands/plugins.js +9 -6
- package/dist/index.js +1 -1
- package/dist/utils/git.d.ts +1 -0
- package/dist/utils/git.js +4 -1
- package/dist/utils/manifest.js +3 -2
- package/package.json +1 -1
|
@@ -4,7 +4,11 @@ interface PluginsAddCommandOptions extends ProjectEnvOptions {
|
|
|
4
4
|
ci?: boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare function pluginsAddCommand(name: string, options?: PluginsAddCommandOptions): Promise<void>;
|
|
7
|
-
|
|
7
|
+
interface PluginsRemoveCommandOptions extends ProjectEnvOptions {
|
|
8
|
+
/** Also remove cache in .codapult/ dir */
|
|
9
|
+
clean?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function pluginsRemoveCommand(name: string, options?: PluginsRemoveCommandOptions): Promise<void>;
|
|
8
12
|
export declare function pluginsMigrateCommand(name: string | undefined, options: {
|
|
9
13
|
push?: boolean;
|
|
10
14
|
}): Promise<void>;
|
package/dist/commands/plugins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync, spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { findProjectRoot } from '../utils/project.js';
|
|
5
5
|
import { ENV_FILE_NAME, getProjectEnvSource, } from '../utils/project-env.js';
|
|
@@ -200,9 +200,6 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
200
200
|
dim('Start your dev server: pnpm dev');
|
|
201
201
|
console.log();
|
|
202
202
|
}
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
// codapult plugins remove <name>
|
|
205
|
-
// ---------------------------------------------------------------------------
|
|
206
203
|
export async function pluginsRemoveCommand(name, options = {}) {
|
|
207
204
|
const root = findProjectRoot();
|
|
208
205
|
if (!root) {
|
|
@@ -275,11 +272,17 @@ export async function pluginsRemoveCommand(name, options = {}) {
|
|
|
275
272
|
success('Environment variables removed');
|
|
276
273
|
}
|
|
277
274
|
}
|
|
278
|
-
// 8. Remove
|
|
275
|
+
// 8. Remove cache
|
|
276
|
+
if (options.clean && pluginDir) {
|
|
277
|
+
info('Removing cache...');
|
|
278
|
+
rmSync(pluginDir, { recursive: true, force: true });
|
|
279
|
+
success('Cache removed');
|
|
280
|
+
}
|
|
281
|
+
// 9. Remove dependency
|
|
279
282
|
info('Removing dependency...');
|
|
280
283
|
patchPackageJson(root, manifest.name, manifest.package, pluginDir, 'remove');
|
|
281
284
|
success('Dependency removed');
|
|
282
|
-
//
|
|
285
|
+
// 10. pnpm install
|
|
283
286
|
info('Updating dependencies...');
|
|
284
287
|
execQuiet('pnpm install --no-frozen-lockfile', root);
|
|
285
288
|
success('Dependencies updated');
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ withNoEnvFileOption(plugins
|
|
|
47
47
|
.description('install a plugin (local or remote)')
|
|
48
48
|
.option('--from <url>', 'git URL to clone the plugin from')
|
|
49
49
|
.option('--ci', 'CI/Vercel mode: skip pnpm install, db:push, env patching, and interactive prompts')).action(pluginsAddCommand);
|
|
50
|
-
withNoEnvFileOption(plugins.command('remove <name>').description('uninstall a plugin')).action(pluginsRemoveCommand);
|
|
50
|
+
withNoEnvFileOption(plugins.command('remove <name>').description('uninstall a plugin').option('--clean')).action(pluginsRemoveCommand);
|
|
51
51
|
plugins
|
|
52
52
|
.command('migrate [name]')
|
|
53
53
|
.description('update plugin schema and generate DB migration')
|
package/dist/utils/git.d.ts
CHANGED
package/dist/utils/git.js
CHANGED
|
@@ -2,6 +2,9 @@ import { execSync, spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { resolve, basename } from 'node:path';
|
|
4
4
|
const ALLOWED_GIT_URL = /^(https?:\/\/|git@)/;
|
|
5
|
+
export function getCacheDir(projectRoot) {
|
|
6
|
+
return resolve(projectRoot, '.codapult', 'plugins');
|
|
7
|
+
}
|
|
5
8
|
/**
|
|
6
9
|
* Derive a directory name from a git URL.
|
|
7
10
|
*
|
|
@@ -25,7 +28,7 @@ export function clonePlugin(projectRoot, gitUrl) {
|
|
|
25
28
|
throw new Error(`Invalid git URL: "${gitUrl}". Only https:// and git@ URLs are allowed.`);
|
|
26
29
|
}
|
|
27
30
|
const dirName = dirNameFromGitUrl(gitUrl);
|
|
28
|
-
const cacheDir =
|
|
31
|
+
const cacheDir = getCacheDir(projectRoot);
|
|
29
32
|
const pluginDir = resolve(cacheDir, dirName);
|
|
30
33
|
mkdirSync(cacheDir, { recursive: true });
|
|
31
34
|
if (existsSync(resolve(pluginDir, '.git'))) {
|
package/dist/utils/manifest.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { resolve, join, isAbsolute, relative } from 'node:path';
|
|
3
|
+
import { getCacheDir } from './git.js';
|
|
3
4
|
const MANIFEST_FILENAME = 'codapult-plugin.json';
|
|
4
5
|
/**
|
|
5
6
|
* Verifies the resolved directory stays within expected boundaries
|
|
@@ -7,7 +8,7 @@ const MANIFEST_FILENAME = 'codapult-plugin.json';
|
|
|
7
8
|
*/
|
|
8
9
|
function isWithinAllowedScope(dir, projectRoot) {
|
|
9
10
|
const parentDir = resolve(projectRoot, '..');
|
|
10
|
-
const cacheDir =
|
|
11
|
+
const cacheDir = getCacheDir(projectRoot);
|
|
11
12
|
const relToParent = relative(parentDir, dir);
|
|
12
13
|
const relToCache = relative(cacheDir, dir);
|
|
13
14
|
const isUnderParent = !relToParent.startsWith('..') && !isAbsolute(relToParent);
|
|
@@ -25,7 +26,7 @@ export function resolveManifest(projectRoot, nameOrPath) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
// 2. Local cache (.codapult/plugins/codapult-plugin-<name>, ../<name>)
|
|
28
|
-
const cacheDir =
|
|
29
|
+
const cacheDir = getCacheDir(projectRoot);
|
|
29
30
|
candidates.push(join(cacheDir, `codapult-plugin-${nameOrPath}`), join(cacheDir, `codapult-${nameOrPath}`), join(cacheDir, nameOrPath));
|
|
30
31
|
// 3. Sibling directories (../codapult-plugin-<name>, ../codapult-<name>, ../<name>)
|
|
31
32
|
const parentDir = resolve(projectRoot, '..');
|