dropsh 0.2.0 → 0.2.1
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/dropsh-src +0 -0
- package/dist/src/core/auth/registry.js +13 -0
- package/dist/src/index.js +27 -3
- package/package.json +30 -17
package/bin/dropsh-src
CHANGED
|
File without changes
|
|
@@ -7,3 +7,16 @@ export function loginCapableProviders(providers) {
|
|
|
7
7
|
export function providerById(providers, id) {
|
|
8
8
|
return providers.find((p) => p.id === id);
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A session-less provider (e.g. static Basic) is the sole configured provider
|
|
12
|
+
* that declares no login capability: it carries credentials inline and needs no
|
|
13
|
+
* stored session. Used by both resolveAuth and authStatus.
|
|
14
|
+
*/
|
|
15
|
+
export function sessionlessProvider(providers) {
|
|
16
|
+
if (providers.length !== 1)
|
|
17
|
+
return undefined;
|
|
18
|
+
const only = providers[0];
|
|
19
|
+
if (!only)
|
|
20
|
+
return undefined;
|
|
21
|
+
return only.capabilities.login === false ? only : undefined;
|
|
22
|
+
}
|
package/dist/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { applyOperationSchemaPlugins, operationHookPluginIds, runSchema, SCHEMA_
|
|
|
9
9
|
import { runSearch } from "./commands/search.js";
|
|
10
10
|
import { runUpdate } from "./commands/update.js";
|
|
11
11
|
import { runUploadFile } from "./commands/upload-file.js";
|
|
12
|
-
import { collectProviders, providerById } from "./core/auth/registry.js";
|
|
12
|
+
import { collectProviders, providerById, sessionlessProvider } from "./core/auth/registry.js";
|
|
13
13
|
import { readSession, writeSession } from "./core/auth/session-store.js";
|
|
14
14
|
import { createFileStore } from "./core/cache/file-store.js";
|
|
15
15
|
import { createOutput } from "./core/cli/output.js";
|
|
@@ -25,10 +25,20 @@ function resolveConfigPath(override) {
|
|
|
25
25
|
return override ?? process.env.DROPSH_CONFIG ?? "dropsh.config.js";
|
|
26
26
|
}
|
|
27
27
|
export async function resolveAuth(deps) {
|
|
28
|
+
const providers = collectProviders(deps.plugins);
|
|
28
29
|
const rec = await readSession(deps.baseUrl, deps.stateDir);
|
|
29
|
-
if (!rec)
|
|
30
|
+
if (!rec) {
|
|
31
|
+
const sessionless = sessionlessProvider(providers);
|
|
32
|
+
if (sessionless) {
|
|
33
|
+
return sessionless.createAdapter(undefined, {
|
|
34
|
+
http: deps.http,
|
|
35
|
+
now: deps.now,
|
|
36
|
+
save: async () => { },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
30
39
|
throw new AuthError("Not authenticated. Run 'dropsh auth login'.");
|
|
31
|
-
|
|
40
|
+
}
|
|
41
|
+
const provider = providerById(providers, rec.activeProvider);
|
|
32
42
|
if (!provider)
|
|
33
43
|
throw new ConfigError(`active provider '${rec.activeProvider}' is not configured`);
|
|
34
44
|
return provider.createAdapter(rec.session, {
|
|
@@ -37,6 +47,20 @@ export async function resolveAuth(deps) {
|
|
|
37
47
|
save: (session) => writeSession(deps.baseUrl, provider.id, session, deps.stateDir),
|
|
38
48
|
});
|
|
39
49
|
}
|
|
50
|
+
export async function authStatus(deps) {
|
|
51
|
+
const providers = collectProviders(deps.plugins);
|
|
52
|
+
const rec = await readSession(deps.baseUrl, deps.stateDir);
|
|
53
|
+
if (!rec) {
|
|
54
|
+
const sessionless = sessionlessProvider(providers);
|
|
55
|
+
return sessionless
|
|
56
|
+
? { loggedIn: true, provider: sessionless.id, sessionless: true }
|
|
57
|
+
: { loggedIn: false };
|
|
58
|
+
}
|
|
59
|
+
const provider = providerById(providers, rec.activeProvider);
|
|
60
|
+
if (!provider)
|
|
61
|
+
return { loggedIn: false };
|
|
62
|
+
return provider.status(rec.session);
|
|
63
|
+
}
|
|
40
64
|
async function defaultContext(configPath) {
|
|
41
65
|
const cfg = await loadConfig(configPath);
|
|
42
66
|
const http = createHttpClient({ timeoutMs: cfg.defaults.timeout_ms });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dropsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Entity-agnostic helper CLI for Drupal 11 JSON:API, used by the dropsh Claude skill for editorial publishing workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,22 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"build:packages": "pnpm --filter \"./packages/*\" run build",
|
|
23
|
+
"build:plugins": "pnpm --filter \"./plugins/*\" run build",
|
|
24
|
+
"dev": "tsx src/index.ts",
|
|
25
|
+
"test": "vitest run --passWithNoTests",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"test:integration": "pnpm run build && pnpm run build:packages && vitest run -c vitest.config.integration.ts",
|
|
28
|
+
"typecheck": "pnpm run build:packages && tsc --noEmit && pnpm -r run typecheck",
|
|
29
|
+
"lint": "biome check src/ packages/ plugins/ tests/integrations/helpers/ tests/integrations/schema/ tests/integrations/*.ts",
|
|
30
|
+
"lint:fix": "biome check --write src/ packages/ plugins/ tests/integrations/helpers/ tests/integrations/schema/ tests/integrations/*.ts",
|
|
31
|
+
"drupal:up": "bash tests/integrations/bin/drupal-up.sh",
|
|
32
|
+
"drupal:down": "bash tests/integrations/bin/drupal-down.sh",
|
|
33
|
+
"prepublishOnly": "pnpm run typecheck && pnpm run build",
|
|
34
|
+
"release": "node scripts/release.mjs"
|
|
35
|
+
},
|
|
20
36
|
"keywords": [
|
|
21
37
|
"drupal",
|
|
22
38
|
"drupal11",
|
|
@@ -46,22 +62,19 @@
|
|
|
46
62
|
"vite": "^6.4.3",
|
|
47
63
|
"vitest": "^4.1.8"
|
|
48
64
|
},
|
|
65
|
+
"pnpm": {
|
|
66
|
+
"onlyBuiltDependencies": [
|
|
67
|
+
"esbuild"
|
|
68
|
+
],
|
|
69
|
+
"overrides": {
|
|
70
|
+
"fast-uri": "^3.1.2",
|
|
71
|
+
"qs": "^6.15.2",
|
|
72
|
+
"vite": "^6.4.2",
|
|
73
|
+
"esbuild": "^0.25.0"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
49
76
|
"engines": {
|
|
50
77
|
"node": ">=20"
|
|
51
78
|
},
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
"build:packages": "pnpm --filter \"./packages/*\" run build",
|
|
55
|
-
"build:plugins": "pnpm --filter \"./plugins/*\" run build",
|
|
56
|
-
"dev": "tsx src/index.ts",
|
|
57
|
-
"test": "vitest run --passWithNoTests",
|
|
58
|
-
"test:watch": "vitest",
|
|
59
|
-
"test:integration": "pnpm run build && pnpm run build:packages && vitest run -c vitest.config.integration.ts",
|
|
60
|
-
"typecheck": "pnpm run build:packages && tsc --noEmit && pnpm -r run typecheck",
|
|
61
|
-
"lint": "biome check src/ packages/ plugins/ tests/integrations/helpers/ tests/integrations/schema/ tests/integrations/*.ts",
|
|
62
|
-
"lint:fix": "biome check --write src/ packages/ plugins/ tests/integrations/helpers/ tests/integrations/schema/ tests/integrations/*.ts",
|
|
63
|
-
"drupal:up": "bash tests/integrations/bin/drupal-up.sh",
|
|
64
|
-
"drupal:down": "bash tests/integrations/bin/drupal-down.sh",
|
|
65
|
-
"release": "node scripts/release.mjs"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
79
|
+
"packageManager": "pnpm@10.29.1"
|
|
80
|
+
}
|