@rrlab/cli 0.0.3-git-aeeb52d.0 → 0.0.3
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/cli.usage.kdl +1 -1
- package/dist/run.mjs +6 -4
- package/package.json +3 -3
- package/src/program/commands/plugins.ts +12 -6
package/dist/cli.usage.kdl
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @generated by @usage-spec/commander from Commander.js metadata
|
|
2
2
|
name rr
|
|
3
3
|
bin rr
|
|
4
|
-
version "0.0.3
|
|
4
|
+
version "0.0.3"
|
|
5
5
|
usage "<command...> [options...]"
|
|
6
6
|
flag --usage help="print KDL spec for this CLI (https://kdl.dev)"
|
|
7
7
|
cmd completion help="print shell completion script (usage)" {
|
package/dist/run.mjs
CHANGED
|
@@ -863,7 +863,7 @@ async function runAdd(ctx, name, opts) {
|
|
|
863
863
|
const ast = new ConfigAstService();
|
|
864
864
|
const loaded = await ast.load(ctx.appPkg.dirPath);
|
|
865
865
|
const inConfig = !loaded.isNew && ast.hasPlugin(loaded.mod, exportName);
|
|
866
|
-
if (inPkg && inConfig && !opts.force) {
|
|
866
|
+
if (inPkg && inConfig && !opts.force && !spec) {
|
|
867
867
|
clack.log.warn(`${pkgName} is already installed and configured. Use --force to re-run install.`);
|
|
868
868
|
clack.outro("Nothing to do.");
|
|
869
869
|
return;
|
|
@@ -872,8 +872,10 @@ async function runAdd(ctx, name, opts) {
|
|
|
872
872
|
const wsChoice = resolveWorkspaceChoice(ctx.appPkg, pm);
|
|
873
873
|
const workspace = toNypmWorkspace(wsChoice);
|
|
874
874
|
const targetLabel = describeWorkspaceChoice(wsChoice);
|
|
875
|
+
const willInstall = !inPkg || !!spec;
|
|
875
876
|
if (opts.dryRun) {
|
|
876
|
-
|
|
877
|
+
const presence = willInstall ? inPkg ? " (already present, will be updated to this spec)" : "" : " (already present, skipped)";
|
|
878
|
+
clack.log.info(`Would: install ${installSpec} as a devDependency in ${targetLabel}${presence}.`);
|
|
877
879
|
if (!inConfig) {
|
|
878
880
|
const rel = path.relative(ctx.appPkg.dirPath, loaded.filepath) || loaded.filepath;
|
|
879
881
|
clack.log.info(`Would: add ${exportName}() to ${rel} (plugins[]).`);
|
|
@@ -883,7 +885,7 @@ async function runAdd(ctx, name, opts) {
|
|
|
883
885
|
return;
|
|
884
886
|
}
|
|
885
887
|
let installedNow = false;
|
|
886
|
-
if (
|
|
888
|
+
if (willInstall) {
|
|
887
889
|
await withSpinner(`Installing ${installSpec}`, async () => {
|
|
888
890
|
await addDependency([installSpec], {
|
|
889
891
|
cwd: ctx.appPkg.dirPath,
|
|
@@ -892,7 +894,7 @@ async function runAdd(ctx, name, opts) {
|
|
|
892
894
|
workspace
|
|
893
895
|
});
|
|
894
896
|
});
|
|
895
|
-
installedNow = true;
|
|
897
|
+
if (!inPkg) installedNow = true;
|
|
896
898
|
}
|
|
897
899
|
let installResult;
|
|
898
900
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rrlab/cli",
|
|
3
|
-
"version": "0.0.3
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "The CLI toolbox to fullstack common scripts in Variable Land",
|
|
5
5
|
"homepage": "https://github.com/variableland/dx/tree/main/run-run/cli#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"memoize": "10.2.0",
|
|
57
57
|
"nypm": "0.6.0",
|
|
58
58
|
"rimraf": "6.1.3",
|
|
59
|
-
"@vlandoss/
|
|
60
|
-
"@vlandoss/
|
|
59
|
+
"@vlandoss/loggy": "0.2.1",
|
|
60
|
+
"@vlandoss/clibuddy": "0.6.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"tsdown": "0.22.0",
|
|
@@ -93,7 +93,7 @@ async function runAdd(ctx: Context, name: string, opts: AddOptions) {
|
|
|
93
93
|
const loaded = await ast.load(ctx.appPkg.dirPath);
|
|
94
94
|
const inConfig = !loaded.isNew && ast.hasPlugin(loaded.mod, exportName);
|
|
95
95
|
|
|
96
|
-
if (inPkg && inConfig && !opts.force) {
|
|
96
|
+
if (inPkg && inConfig && !opts.force && !spec) {
|
|
97
97
|
clack.log.warn(`${pkgName} is already installed and configured. Use --force to re-run install.`);
|
|
98
98
|
clack.outro("Nothing to do.");
|
|
99
99
|
return;
|
|
@@ -103,11 +103,16 @@ async function runAdd(ctx: Context, name: string, opts: AddOptions) {
|
|
|
103
103
|
const wsChoice = resolveWorkspaceChoice(ctx.appPkg, pm);
|
|
104
104
|
const workspace = toNypmWorkspace(wsChoice);
|
|
105
105
|
const targetLabel = describeWorkspaceChoice(wsChoice);
|
|
106
|
+
// A spec means "(re)install at this spec" — upgrade even when the package is already in package.json.
|
|
107
|
+
const willInstall = !inPkg || !!spec;
|
|
106
108
|
|
|
107
109
|
if (opts.dryRun) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
const presence = willInstall
|
|
111
|
+
? inPkg
|
|
112
|
+
? " (already present, will be updated to this spec)"
|
|
113
|
+
: ""
|
|
114
|
+
: " (already present, skipped)";
|
|
115
|
+
clack.log.info(`Would: install ${installSpec} as a devDependency in ${targetLabel}${presence}.`);
|
|
111
116
|
if (!inConfig) {
|
|
112
117
|
const rel = path.relative(ctx.appPkg.dirPath, loaded.filepath) || loaded.filepath;
|
|
113
118
|
clack.log.info(`Would: add ${exportName}() to ${rel} (plugins[]).`);
|
|
@@ -118,11 +123,12 @@ async function runAdd(ctx: Context, name: string, opts: AddOptions) {
|
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
let installedNow = false;
|
|
121
|
-
if (
|
|
126
|
+
if (willInstall) {
|
|
122
127
|
await withSpinner(`Installing ${installSpec}`, async () => {
|
|
123
128
|
await addDependency([installSpec], { cwd: ctx.appPkg.dirPath, dev: true, silent: true, workspace });
|
|
124
129
|
});
|
|
125
|
-
|
|
130
|
+
// Only mark for rollback when this was a fresh install — a failed upgrade can't be safely reverted to the previous version.
|
|
131
|
+
if (!inPkg) installedNow = true;
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
let installResult: InstallResult | undefined;
|