@sortlist/cli 0.35.0 → 0.37.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/bin/sl.mjs +20 -7
- package/dist/index.js +1579 -0
- package/dist/index.js.map +1 -0
- package/package.json +13 -10
- package/src/codegen.ts +0 -34
- package/src/commands/config.ts +0 -95
- package/src/commands/dynamic.ts +0 -569
- package/src/commands/login.ts +0 -155
- package/src/commands/logout.ts +0 -45
- package/src/commands/token.ts +0 -23
- package/src/commands/whoami.ts +0 -55
- package/src/graphql/client.ts +0 -259
- package/src/graphql/generated/gql.ts +0 -70
- package/src/graphql/generated/graphql.ts +0 -4757
- package/src/graphql/generated/index.ts +0 -1
- package/src/graphql/introspection.ts +0 -240
- package/src/graphql/operations/common.ts +0 -16
- package/src/graphql/operations/hermes.ts +0 -54
- package/src/graphql/query-builder.ts +0 -239
- package/src/index.ts +0 -186
- package/src/lib/auth.ts +0 -58
- package/src/lib/browser.ts +0 -11
- package/src/lib/company.ts +0 -15
- package/src/lib/config.ts +0 -80
- package/src/lib/env.ts +0 -10
- package/src/lib/output.ts +0 -58
- package/src/lib/sentry.ts +0 -70
- package/src/lib/version-check.ts +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sortlist/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Sortlist platform CLI — GraphQL federation client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -14,35 +14,35 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"bin/",
|
|
17
|
-
"
|
|
18
|
-
"codegen.ts",
|
|
17
|
+
"dist/",
|
|
19
18
|
".published"
|
|
20
19
|
],
|
|
21
20
|
"scripts": {
|
|
22
21
|
"codegen": "graphql-codegen --config src/codegen.ts",
|
|
23
22
|
"generate": "npm run codegen",
|
|
23
|
+
"build": "tsup",
|
|
24
24
|
"type-check": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run",
|
|
25
26
|
"lint": "eslint . --ext .ts,.tsx,.js,.cjs --quiet",
|
|
26
27
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,cjs,json}\"",
|
|
27
28
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,cjs,json}\"",
|
|
28
29
|
"prepare": "[ -n \"$CI\" ] && exit 0; command -v git >/dev/null 2>&1 && git config --unset core.hooksPath || true; command -v lefthook >/dev/null 2>&1 && lefthook install || true"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@sentry/node": "^10.29.0",
|
|
32
|
-
"@graphql-codegen/cli": "^6.2.1",
|
|
33
|
-
"@graphql-codegen/client-preset": "^5.2.4",
|
|
34
32
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
33
|
+
"@sentry/node": "^10.29.0",
|
|
35
34
|
"commander": "^13.0.0",
|
|
36
|
-
"graphql": "^16.13.2"
|
|
37
|
-
"tsx": "^4.19.0"
|
|
35
|
+
"graphql": "^16.13.2"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
38
|
"@commitlint/config-conventional": "^18.6.1",
|
|
39
|
+
"@graphql-codegen/cli": "^6.2.1",
|
|
40
|
+
"@graphql-codegen/client-preset": "^5.2.4",
|
|
41
41
|
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
|
|
42
42
|
"@types/node": "^22.10.0",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
44
44
|
"@typescript-eslint/parser": "^8.13.0",
|
|
45
|
-
"branch-name-lint": "^
|
|
45
|
+
"branch-name-lint": "^3.0.1",
|
|
46
46
|
"commitlint": "^18.6.1",
|
|
47
47
|
"eslint": "^8.56.0",
|
|
48
48
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
"eslint-plugin-sonarjs": "^0.24.0",
|
|
53
53
|
"lefthook": "^1.11.5",
|
|
54
54
|
"prettier": "^3.5.3",
|
|
55
|
-
"
|
|
55
|
+
"tsup": "^8.5.1",
|
|
56
|
+
"tsx": "^4.19.0",
|
|
57
|
+
"typescript": "^5.7.0",
|
|
58
|
+
"vitest": "^4.1.10"
|
|
56
59
|
}
|
|
57
60
|
}
|
package/src/codegen.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
3
|
-
|
|
4
|
-
// Schema resolution: SUPERGRAPH_PATH env → ../backend/supergraph.graphql
|
|
5
|
-
function resolveSchema(): string {
|
|
6
|
-
if (process.env.SUPERGRAPH_PATH && fs.existsSync(process.env.SUPERGRAPH_PATH)) {
|
|
7
|
-
return process.env.SUPERGRAPH_PATH;
|
|
8
|
-
}
|
|
9
|
-
const local = '../../backend/supergraph.graphql';
|
|
10
|
-
if (fs.existsSync(local)) return local;
|
|
11
|
-
throw new Error('Supergraph not found. Set SUPERGRAPH_PATH or ensure ../backend/supergraph.graphql exists.');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const config: CodegenConfig = {
|
|
15
|
-
overwrite: true,
|
|
16
|
-
schema: resolveSchema(),
|
|
17
|
-
documents: ['src/graphql/operations/*.ts'],
|
|
18
|
-
emitLegacyCommonJSImports: false,
|
|
19
|
-
generates: {
|
|
20
|
-
'src/graphql/generated/': {
|
|
21
|
-
preset: 'client',
|
|
22
|
-
config: {
|
|
23
|
-
useTypeImports: true,
|
|
24
|
-
enumsAsTypes: true,
|
|
25
|
-
},
|
|
26
|
-
presetConfig: {
|
|
27
|
-
gqlTagName: 'gql',
|
|
28
|
-
fragmentMasking: false,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default config;
|
package/src/commands/config.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
|
|
3
|
-
import { clearCredentials } from '../lib/auth.ts';
|
|
4
|
-
import { loadConfig, resetConfig, saveConfig } from '../lib/config.ts';
|
|
5
|
-
import { isLocalDev } from '../lib/env.ts';
|
|
6
|
-
import { error, hint, info, isJsonMode, printJson, success } from '../lib/output.ts';
|
|
7
|
-
|
|
8
|
-
const PRODUCTION_ENDPOINT = 'https://federation.sortlist.com/graphql';
|
|
9
|
-
const STAGING_ENDPOINT = 'https://federation.sortlist-test.com/graphql';
|
|
10
|
-
const LOCAL_ENDPOINT = 'http://localhost:4020/graphql';
|
|
11
|
-
|
|
12
|
-
export const configCommand = new Command('config')
|
|
13
|
-
.summary('View or update CLI configuration')
|
|
14
|
-
.description(
|
|
15
|
-
'View or update CLI configuration\n\n' +
|
|
16
|
-
'Manage your company context and credentials.\n\n' +
|
|
17
|
-
'Examples:\n' +
|
|
18
|
-
' sl config show See current endpoint and company\n' +
|
|
19
|
-
(isLocalDev ? ' sl config set endpoint <url> Point to a custom endpoint\n' : '') +
|
|
20
|
-
' sl config reset Clear all config and credentials',
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
configCommand
|
|
24
|
-
.command('show')
|
|
25
|
-
.description('Show current configuration')
|
|
26
|
-
.action(function (this: Command) {
|
|
27
|
-
const opts = this.optsWithGlobals();
|
|
28
|
-
const config = loadConfig();
|
|
29
|
-
if (isJsonMode(opts)) {
|
|
30
|
-
printJson(config);
|
|
31
|
-
} else {
|
|
32
|
-
info(`Endpoint: ${config.endpoint}`);
|
|
33
|
-
if (config.oauthId) info(`User: ${config.oauthId}`);
|
|
34
|
-
if (config.companyId) info(`Company ID: ${config.companyId}`);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
configCommand
|
|
39
|
-
.command('set <key> <value>')
|
|
40
|
-
.description(`Set a config value (${isLocalDev ? 'endpoint, ' : ''}companyId)`)
|
|
41
|
-
.action((key: string, value: string) => {
|
|
42
|
-
// `endpoint` is dev-only — published builds always target production, so the
|
|
43
|
-
// endpoint must not be overridable there (mirrors the gated use-* commands).
|
|
44
|
-
const allowed = [...(isLocalDev ? ['endpoint'] : []), 'companyId', 'oauthId'];
|
|
45
|
-
if (!allowed.includes(key)) {
|
|
46
|
-
error(`Unknown config key: "${key}".`);
|
|
47
|
-
info('');
|
|
48
|
-
info(' Allowed keys:');
|
|
49
|
-
for (const k of allowed) {
|
|
50
|
-
info(` ${k}`);
|
|
51
|
-
}
|
|
52
|
-
hint('Usage: sl config set <key> <value>');
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
saveConfig({ [key]: value });
|
|
56
|
-
success(`Set ${key} = ${value}`);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (isLocalDev) {
|
|
60
|
-
configCommand
|
|
61
|
-
.command('use-production')
|
|
62
|
-
.description('Point CLI to production (federation.sortlist.com)')
|
|
63
|
-
.action(() => {
|
|
64
|
-
saveConfig({ endpoint: PRODUCTION_ENDPOINT });
|
|
65
|
-
success(`Endpoint set to ${PRODUCTION_ENDPOINT}`);
|
|
66
|
-
hint('Run `sl login` to authenticate against production.');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
configCommand
|
|
70
|
-
.command('use-staging')
|
|
71
|
-
.description('Point CLI to staging (federation.sortlist-test.com)')
|
|
72
|
-
.action(() => {
|
|
73
|
-
saveConfig({ endpoint: STAGING_ENDPOINT });
|
|
74
|
-
success(`Endpoint set to ${STAGING_ENDPOINT}`);
|
|
75
|
-
hint('Run `sl login` to authenticate against staging.');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
configCommand
|
|
79
|
-
.command('use-local')
|
|
80
|
-
.description('Point CLI to local development (localhost:4020)')
|
|
81
|
-
.action(() => {
|
|
82
|
-
saveConfig({ endpoint: LOCAL_ENDPOINT });
|
|
83
|
-
success(`Endpoint set to ${LOCAL_ENDPOINT}`);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
configCommand
|
|
88
|
-
.command('reset')
|
|
89
|
-
.description('Reset all config and credentials')
|
|
90
|
-
.action(() => {
|
|
91
|
-
resetConfig();
|
|
92
|
-
clearCredentials();
|
|
93
|
-
success('Config and credentials cleared.');
|
|
94
|
-
hint('Run `sl login` to re-authenticate.');
|
|
95
|
-
});
|