@grantjs/cli 1.18.1 → 1.18.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/index.mjs +26 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
9
9
|
import { homedir, platform } from "node:os";
|
|
10
10
|
import { createServer } from "node:http";
|
|
11
11
|
import inquirer from "inquirer";
|
|
12
|
-
|
|
12
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
13
13
|
/**
|
|
14
14
|
* CommanderError class
|
|
15
15
|
*/
|
|
@@ -43,8 +43,7 @@ var InvalidArgumentError = class extends CommanderError {
|
|
|
43
43
|
this.name = this.constructor.name;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
//#region ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/argument.js
|
|
46
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/argument.js
|
|
48
47
|
var Argument = class {
|
|
49
48
|
/**
|
|
50
49
|
* Initialize a new command argument with the given name and description.
|
|
@@ -162,8 +161,7 @@ function humanReadableArgName(arg) {
|
|
|
162
161
|
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
163
162
|
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
//#region ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/help.js
|
|
164
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/help.js
|
|
167
165
|
/**
|
|
168
166
|
* TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS`
|
|
169
167
|
* https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types
|
|
@@ -637,8 +635,7 @@ var Help = class {
|
|
|
637
635
|
return wrappedLines.join("\n");
|
|
638
636
|
}
|
|
639
637
|
};
|
|
640
|
-
|
|
641
|
-
//#region ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/option.js
|
|
638
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/option.js
|
|
642
639
|
var Option = class {
|
|
643
640
|
/**
|
|
644
641
|
* Initialize a new `Option` with the given `flags` and `description`.
|
|
@@ -935,8 +932,7 @@ function splitOptionFlags(flags) {
|
|
|
935
932
|
longFlag
|
|
936
933
|
};
|
|
937
934
|
}
|
|
938
|
-
|
|
939
|
-
//#region ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
|
|
935
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/suggestSimilar.js
|
|
940
936
|
var maxDistance = 3;
|
|
941
937
|
function editDistance(a, b) {
|
|
942
938
|
if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
|
|
@@ -987,8 +983,7 @@ function suggestSimilar(word, candidates) {
|
|
|
987
983
|
if (similar.length === 1) return `\n(Did you mean ${similar[0]}?)`;
|
|
988
984
|
return "";
|
|
989
985
|
}
|
|
990
|
-
|
|
991
|
-
//#region ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
|
|
986
|
+
// ../../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/command.js
|
|
992
987
|
var Command = class Command extends EventEmitter {
|
|
993
988
|
/**
|
|
994
989
|
* Initialize a new `Command`.
|
|
@@ -2963,8 +2958,7 @@ function useColor() {
|
|
|
2963
2958
|
if (process$1.env.FORCE_COLOR || process$1.env.CLICOLOR_FORCE !== void 0) return true;
|
|
2964
2959
|
}
|
|
2965
2960
|
new Command();
|
|
2966
|
-
|
|
2967
|
-
//#region src/config/storage.ts
|
|
2961
|
+
// src/config/storage.ts
|
|
2968
2962
|
var CONFIG_DIR_NAME = "grant";
|
|
2969
2963
|
var CONFIG_FILE_NAME = "config.json";
|
|
2970
2964
|
var DEFAULT_PROFILE_NAME = "default";
|
|
@@ -3074,8 +3068,7 @@ async function loadProfile(profileFlag) {
|
|
|
3074
3068
|
profileName
|
|
3075
3069
|
};
|
|
3076
3070
|
}
|
|
3077
|
-
|
|
3078
|
-
//#region src/config/credentials.ts
|
|
3071
|
+
// src/config/credentials.ts
|
|
3079
3072
|
var ENV = {
|
|
3080
3073
|
profile: "GRANT_PROFILE",
|
|
3081
3074
|
apiUrl: "GRANT_API_URL",
|
|
@@ -3189,8 +3182,7 @@ function handleCliError(err) {
|
|
|
3189
3182
|
console.error(message);
|
|
3190
3183
|
process.exit(isAuthFailure(0, message) ? 2 : 1);
|
|
3191
3184
|
}
|
|
3192
|
-
|
|
3193
|
-
//#region src/api/transport.ts
|
|
3185
|
+
// src/api/transport.ts
|
|
3194
3186
|
var DEBUG = process.env.GRANT_CLI_DEBUG === "1" || process.env.GRANT_CLI_DEBUG === "true";
|
|
3195
3187
|
function joinUrl(apiUrl, path) {
|
|
3196
3188
|
const base = apiUrl.replace(/\/+$/, "");
|
|
@@ -3254,8 +3246,7 @@ async function apiRequest(req) {
|
|
|
3254
3246
|
data
|
|
3255
3247
|
};
|
|
3256
3248
|
}
|
|
3257
|
-
|
|
3258
|
-
//#region src/api/client.ts
|
|
3249
|
+
// src/api/client.ts
|
|
3259
3250
|
/**
|
|
3260
3251
|
* Minimal REST client for Grant API.
|
|
3261
3252
|
* Used by start (token exchange) and generate-types (resources/permissions).
|
|
@@ -3567,8 +3558,7 @@ async function fetchPermissions(baseUrl, accessToken, scope, originVerifySecret)
|
|
|
3567
3558
|
}
|
|
3568
3559
|
return items;
|
|
3569
3560
|
}
|
|
3570
|
-
|
|
3571
|
-
//#region src/config/resolve-token.ts
|
|
3561
|
+
// src/config/resolve-token.ts
|
|
3572
3562
|
/**
|
|
3573
3563
|
* Resolve a valid access token from env or stored config.
|
|
3574
3564
|
* API key: exchanges clientId + clientSecret for a fresh token.
|
|
@@ -3606,8 +3596,7 @@ async function refreshAndPersistSession(config, profileName) {
|
|
|
3606
3596
|
}
|
|
3607
3597
|
return rotated.accessToken;
|
|
3608
3598
|
}
|
|
3609
|
-
|
|
3610
|
-
//#region src/api/authenticated.ts
|
|
3599
|
+
// src/api/authenticated.ts
|
|
3611
3600
|
var REAUTH_HINT = "Session expired or unauthorized. Run \"grant start\" again, or use an api-key profile / GRANT_ACCESS_TOKEN.";
|
|
3612
3601
|
async function authenticatedRequest(req) {
|
|
3613
3602
|
const ctx = await resolveRuntimeContext(req.flags);
|
|
@@ -3642,8 +3631,7 @@ async function authenticatedRequest(req) {
|
|
|
3642
3631
|
}
|
|
3643
3632
|
}
|
|
3644
3633
|
}
|
|
3645
|
-
|
|
3646
|
-
//#region src/config/output.ts
|
|
3634
|
+
// src/config/output.ts
|
|
3647
3635
|
function defaultOutputFormat() {
|
|
3648
3636
|
return process.stdout.isTTY ? "text" : "json";
|
|
3649
3637
|
}
|
|
@@ -3665,8 +3653,7 @@ function printOutput(data, format) {
|
|
|
3665
3653
|
}
|
|
3666
3654
|
console.log(JSON.stringify(data, null, 2));
|
|
3667
3655
|
}
|
|
3668
|
-
|
|
3669
|
-
//#region src/commands/api.ts
|
|
3656
|
+
// src/commands/api.ts
|
|
3670
3657
|
function parseQuery$1(pairs) {
|
|
3671
3658
|
const query = {};
|
|
3672
3659
|
for (const pair of pairs ?? []) {
|
|
@@ -3710,8 +3697,7 @@ function createApiCommand(program) {
|
|
|
3710
3697
|
}
|
|
3711
3698
|
});
|
|
3712
3699
|
}
|
|
3713
|
-
|
|
3714
|
-
//#region src/commands/config-cmd.ts
|
|
3700
|
+
// src/commands/config-cmd.ts
|
|
3715
3701
|
var VALID_TENANTS = ["accountProject", "organizationProject"];
|
|
3716
3702
|
async function requireProfile(profileFlag) {
|
|
3717
3703
|
const result = await loadProfile(profileFlag);
|
|
@@ -3931,8 +3917,7 @@ function createConfigCommand(program) {
|
|
|
3931
3917
|
console.log("default profile set to", trimmed);
|
|
3932
3918
|
});
|
|
3933
3919
|
}
|
|
3934
|
-
|
|
3935
|
-
//#region src/spec/map-commands.ts
|
|
3920
|
+
// src/spec/map-commands.ts
|
|
3936
3921
|
function kebab(value) {
|
|
3937
3922
|
return value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
3938
3923
|
}
|
|
@@ -3997,8 +3982,7 @@ function applyPathParams(path, values) {
|
|
|
3997
3982
|
function flagName(param) {
|
|
3998
3983
|
return kebab(param);
|
|
3999
3984
|
}
|
|
4000
|
-
|
|
4001
|
-
//#region src/spec/operations.ts
|
|
3985
|
+
// src/spec/operations.ts
|
|
4002
3986
|
/** Generated by scripts/vendor-cli-openapi.mjs — do not edit by hand. */
|
|
4003
3987
|
var vendoredOperations = [
|
|
4004
3988
|
{
|
|
@@ -5106,8 +5090,7 @@ var vendoredOperations = [
|
|
|
5106
5090
|
pathParams: []
|
|
5107
5091
|
}
|
|
5108
5092
|
];
|
|
5109
|
-
|
|
5110
|
-
//#region src/commands/from-spec.ts
|
|
5093
|
+
// src/commands/from-spec.ts
|
|
5111
5094
|
var SKIP_PATHS = /* @__PURE__ */ new Set([
|
|
5112
5095
|
"/api/auth/login",
|
|
5113
5096
|
"/api/auth/register",
|
|
@@ -5172,8 +5155,7 @@ function createSpecCommands(program) {
|
|
|
5172
5155
|
}
|
|
5173
5156
|
}
|
|
5174
5157
|
}
|
|
5175
|
-
|
|
5176
|
-
//#region src/commands/generate-types-impl.ts
|
|
5158
|
+
// src/commands/generate-types-impl.ts
|
|
5177
5159
|
/**
|
|
5178
5160
|
* Generate TypeScript content for ResourceSlug and ResourceAction from project data.
|
|
5179
5161
|
* Mirrors the shape of @grantjs/constants permissions/resources.ts.
|
|
@@ -5216,8 +5198,7 @@ function generateTypesContent(slugs, actions) {
|
|
|
5216
5198
|
""
|
|
5217
5199
|
].join("\n");
|
|
5218
5200
|
}
|
|
5219
|
-
|
|
5220
|
-
//#region src/commands/generate-types.ts
|
|
5201
|
+
// src/commands/generate-types.ts
|
|
5221
5202
|
var DEFAULT_OUTPUT = "./grant-types.ts";
|
|
5222
5203
|
function createGenerateTypesCommand(program) {
|
|
5223
5204
|
program.command("generate-types").description("Query the selected project's resources and permissions, then generate ResourceSlug and ResourceAction TypeScript constants").option("-p, --profile <name>", "Profile to use (default: default profile)").option("-o, --output <path>", "Output file path (default: from grant start, or ./grant-types.ts)").option("--dry-run", "Print what would be generated without writing").addHelpText("after", "\nExample:\n grant generate-types --profile staging -o ./src/grant-types.ts\n").action(async (options) => {
|
|
@@ -5261,8 +5242,7 @@ function createGenerateTypesCommand(program) {
|
|
|
5261
5242
|
}
|
|
5262
5243
|
});
|
|
5263
5244
|
}
|
|
5264
|
-
|
|
5265
|
-
//#region src/commands/start.ts
|
|
5245
|
+
// src/commands/start.ts
|
|
5266
5246
|
var AUTH_SESSION = "session";
|
|
5267
5247
|
var AUTH_API_KEY = "api-key";
|
|
5268
5248
|
var PROJECT_TENANTS = [{
|
|
@@ -5710,13 +5690,11 @@ function createStartCommand(program) {
|
|
|
5710
5690
|
if (config.generateTypesOutputPath) console.log(" Generate-types output:", config.generateTypesOutputPath);
|
|
5711
5691
|
});
|
|
5712
5692
|
}
|
|
5713
|
-
|
|
5714
|
-
//#region src/utils/package.ts
|
|
5693
|
+
// src/utils/package.ts
|
|
5715
5694
|
function getPackageVersion() {
|
|
5716
|
-
return "1.18.
|
|
5695
|
+
return "1.18.3";
|
|
5717
5696
|
}
|
|
5718
|
-
|
|
5719
|
-
//#region src/commands/version.ts
|
|
5697
|
+
// src/commands/version.ts
|
|
5720
5698
|
function createVersionCommand(program) {
|
|
5721
5699
|
program.command("version").description("Show CLI version (use -j for JSON)").option("-j, --json", "Output version as JSON").action((options) => {
|
|
5722
5700
|
const version = getPackageVersion();
|
|
@@ -5724,8 +5702,7 @@ function createVersionCommand(program) {
|
|
|
5724
5702
|
else console.log(version);
|
|
5725
5703
|
});
|
|
5726
5704
|
}
|
|
5727
|
-
|
|
5728
|
-
//#region src/commands/whoami.ts
|
|
5705
|
+
// src/commands/whoami.ts
|
|
5729
5706
|
function createWhoamiCommand(program) {
|
|
5730
5707
|
program.command("whoami").description("Show the authenticated caller (GET /api/me)").option("-p, --profile <name>", "Profile to use (or GRANT_PROFILE)").option("--output <format>", "json or text").option("--scope-id <id>", "Override selected scope id").option("--tenant <tenant>", "Override selected scope tenant").action(async (options) => {
|
|
5731
5708
|
try {
|
|
@@ -5753,8 +5730,7 @@ function createWhoamiCommand(program) {
|
|
|
5753
5730
|
}
|
|
5754
5731
|
});
|
|
5755
5732
|
}
|
|
5756
|
-
|
|
5757
|
-
//#region src/index.ts
|
|
5733
|
+
// src/index.ts
|
|
5758
5734
|
var program = new Command();
|
|
5759
5735
|
program.name("grant").description("Grant CLI - Setup, authentication, and typings generation for @grantjs/server").enablePositionalOptions().addHelpText("after", `
|
|
5760
5736
|
Examples:
|
|
@@ -5778,6 +5754,5 @@ createWhoamiCommand(program);
|
|
|
5778
5754
|
createApiCommand(program);
|
|
5779
5755
|
createSpecCommands(program);
|
|
5780
5756
|
program.parse();
|
|
5781
|
-
//#endregion
|
|
5782
5757
|
|
|
5783
5758
|
//# sourceMappingURL=index.mjs.map
|