@codapult/cli 0.7.1 → 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 -7
- 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 +5 -5
|
@@ -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';
|
|
@@ -168,7 +168,6 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
168
168
|
heading('Done!');
|
|
169
169
|
success(`Plugin "${manifest.name}" installed (CI mode).`);
|
|
170
170
|
dim('Skipped: db:push, env patching, optional deps.');
|
|
171
|
-
dim('Run pnpm install separately after this command.');
|
|
172
171
|
console.log();
|
|
173
172
|
return;
|
|
174
173
|
}
|
|
@@ -201,9 +200,6 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
201
200
|
dim('Start your dev server: pnpm dev');
|
|
202
201
|
console.log();
|
|
203
202
|
}
|
|
204
|
-
// ---------------------------------------------------------------------------
|
|
205
|
-
// codapult plugins remove <name>
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
203
|
export async function pluginsRemoveCommand(name, options = {}) {
|
|
208
204
|
const root = findProjectRoot();
|
|
209
205
|
if (!root) {
|
|
@@ -276,11 +272,17 @@ export async function pluginsRemoveCommand(name, options = {}) {
|
|
|
276
272
|
success('Environment variables removed');
|
|
277
273
|
}
|
|
278
274
|
}
|
|
279
|
-
// 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
|
|
280
282
|
info('Removing dependency...');
|
|
281
283
|
patchPackageJson(root, manifest.name, manifest.package, pluginDir, 'remove');
|
|
282
284
|
success('Dependency removed');
|
|
283
|
-
//
|
|
285
|
+
// 10. pnpm install
|
|
284
286
|
info('Updating dependencies...');
|
|
285
287
|
execQuiet('pnpm install --no-frozen-lockfile', root);
|
|
286
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, '..');
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codapult/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Codapult CLI — manage, update, and diagnose your Codapult SaaS project",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"packageManager": "pnpm@10.33.2",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20.19.0"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"bin": {
|
|
8
12
|
"codapult": "./dist/index.js"
|
|
@@ -70,9 +74,5 @@
|
|
|
70
74
|
"@release-it/conventional-changelog>release-it": ">=18"
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
|
-
},
|
|
74
|
-
"packageManager": "pnpm@10.0.0",
|
|
75
|
-
"engines": {
|
|
76
|
-
"node": ">=20.19.0"
|
|
77
77
|
}
|
|
78
78
|
}
|