@ecomweb/cli 0.7.0 → 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/README.md +56 -32
- package/dist/base-command.d.ts +8 -0
- package/dist/base-command.js +43 -4
- package/dist/base-command.js.map +1 -1
- package/dist/commands/auth/login.d.ts +6 -4
- package/dist/commands/auth/login.js +117 -89
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js +28 -9
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/profiles/delete.js +11 -0
- package/dist/commands/auth/profiles/delete.js.map +1 -1
- package/dist/commands/auth/profiles/list.js +2 -2
- package/dist/commands/auth/profiles/list.js.map +1 -1
- package/dist/commands/auth/status.js +17 -9
- package/dist/commands/auth/status.js.map +1 -1
- package/dist/commands/{auth/register.d.ts → stores/create.d.ts} +4 -3
- package/dist/commands/stores/create.js +68 -0
- package/dist/commands/stores/create.js.map +1 -0
- package/dist/commands/stores/current.js +1 -1
- package/dist/commands/stores/current.js.map +1 -1
- package/dist/commands/stores/list.js +3 -3
- package/dist/commands/stores/list.js.map +1 -1
- package/dist/commands/stores/switch.js +14 -6
- package/dist/commands/stores/switch.js.map +1 -1
- package/dist/lib/api-client.d.ts +5 -4
- package/dist/lib/api-client.js +32 -16
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/codex-skill.d.ts +1 -1
- package/dist/lib/codex-skill.js +12 -8
- package/dist/lib/codex-skill.js.map +1 -1
- package/dist/lib/config.d.ts +6 -18
- package/dist/lib/config.js +35 -64
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/credential-store.d.ts +44 -0
- package/dist/lib/credential-store.js +137 -0
- package/dist/lib/credential-store.js.map +1 -0
- package/dist/lib/device-login.d.ts +22 -0
- package/dist/lib/device-login.js +66 -0
- package/dist/lib/device-login.js.map +1 -0
- package/dist/lib/errors.d.ts +1 -0
- package/dist/lib/errors.js +6 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/file-lock.d.ts +6 -0
- package/dist/lib/file-lock.js +66 -0
- package/dist/lib/file-lock.js.map +1 -0
- package/dist/lib/open-browser.d.ts +13 -0
- package/dist/lib/open-browser.js +38 -0
- package/dist/lib/open-browser.js.map +1 -0
- package/dist/lib/pending-login.d.ts +5 -0
- package/dist/lib/pending-login.js +39 -0
- package/dist/lib/pending-login.js.map +1 -0
- package/dist/lib/secure-file.d.ts +1 -0
- package/dist/lib/secure-file.js +15 -0
- package/dist/lib/secure-file.js.map +1 -0
- package/dist/lib/session.d.ts +40 -0
- package/dist/lib/session.js +80 -0
- package/dist/lib/session.js.map +1 -0
- package/dist/lib/store-selection.d.ts +19 -0
- package/dist/lib/store-selection.js +23 -0
- package/dist/lib/store-selection.js.map +1 -0
- package/oclif.manifest.json +227 -578
- package/package.json +2 -1
- package/dist/commands/auth/register.js +0 -35
- package/dist/commands/auth/register.js.map +0 -1
- package/dist/commands/auth/verify.d.ts +0 -20
- package/dist/commands/auth/verify.js +0 -43
- package/dist/commands/auth/verify.js.map +0 -1
- package/dist/commands/init.d.ts +0 -22
- package/dist/commands/init.js +0 -84
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -19
- package/dist/commands/setup.js +0 -186
- package/dist/commands/setup.js.map +0 -1
- package/dist/lib/email-login.d.ts +0 -35
- package/dist/lib/email-login.js +0 -86
- package/dist/lib/email-login.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":";;AAAA,qDAAiD;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AACjD,6CAAmD;AACnD,mDAAmD;AACnD,2DAAwD;AAExD,MAAqB,UAAW,SAAQ,0BAAW;IASjD,KAAK,CAAC,GAAG;QACP,MAAM,OAAO,GAAG,IAAI,CAAC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O,IAAI,EAAE,OAAO,EAAE,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;;AArCM,sBAAW,GAAG,kDAAkD,CAAC;AAEjE,mBAAQ,GAAG,CAAC,qBAAqB,EAAE,uCAAuC,CAAC,CAAC;AAE5E,gBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAPiB,UAAU"}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const base_command_1 = require("../../../base-command");
|
|
5
|
+
const config_1 = require("../../../lib/config");
|
|
6
|
+
const file_lock_1 = require("../../../lib/file-lock");
|
|
7
|
+
const pending_login_1 = require("../../../lib/pending-login");
|
|
5
8
|
const errors_1 = require("../../../lib/errors");
|
|
6
9
|
class AuthProfilesDelete extends base_command_1.BaseCommand {
|
|
7
10
|
async run() {
|
|
@@ -15,9 +18,17 @@ class AuthProfilesDelete extends base_command_1.BaseCommand {
|
|
|
15
18
|
throw new errors_1.CliError("PROFILE_NOT_FOUND", `Profile "${name}" does not exist.`, errors_1.ExitCode.NOT_FOUND, { hint: `Available profiles: ${profileNames.join(", ")}` });
|
|
16
19
|
}
|
|
17
20
|
const wasActive = this.configManager.getActiveProfileName() === name;
|
|
21
|
+
const revoked = await (0, file_lock_1.withFileLock)(this.lockPathFor(name), async () => {
|
|
22
|
+
const session = this.credentials.get(name);
|
|
23
|
+
const failure = session ? await this.revokeSession(session, name) : undefined;
|
|
24
|
+
this.credentials.delete(name);
|
|
25
|
+
return Boolean(session) && !failure;
|
|
26
|
+
});
|
|
18
27
|
this.configManager.deleteProfile(name);
|
|
28
|
+
(0, pending_login_1.deletePending)(config_1.CREDENTIALS_DIR, name);
|
|
19
29
|
this.outputJson({
|
|
20
30
|
message: `Profile "${name}" deleted.`,
|
|
31
|
+
server_session_revoked: revoked,
|
|
21
32
|
...(wasActive && { note: 'Active profile reset to "default".' }),
|
|
22
33
|
});
|
|
23
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/auth/profiles/delete.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,wDAAoD;AACpD,gDAAyD;AAEzD,MAAqB,kBAAmB,SAAQ,0BAAW;IAkBzD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,iBAAQ,CAChB,uBAAuB,EACvB,oCAAoC,EACpC,iBAAQ,CAAC,UAAU,CACpB,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;QAC1D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,iBAAQ,CAChB,mBAAmB,EACnB,YAAY,IAAI,mBAAmB,EACnC,iBAAQ,CAAC,SAAS,EAClB,EAAE,IAAI,EAAE,uBAAuB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAC3D,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/auth/profiles/delete.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,wDAAoD;AACpD,gDAAsD;AACtD,sDAAsD;AACtD,8DAA2D;AAC3D,gDAAyD;AAEzD,MAAqB,kBAAmB,SAAQ,0BAAW;IAkBzD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC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,IAAI,CAAC,UAAU,CAAC;YACd,OAAO,EAAE,YAAY,IAAI,YAAY;YACrC,sBAAsB,EAAE,OAAO;YAC/B,GAAG,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,oCAAoC,EAAE,CAAC;SACjE,CAAC,CAAC;IACL,CAAC;;AAvDM,8BAAW,GAAG,sCAAsC,CAAC;AAErD,2BAAQ,GAAG;IAChB,sCAAsC;CACvC,CAAC;AAEK,uBAAI,GAAG;IACZ,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,wBAAwB;QACrC,QAAQ,EAAE,IAAI;KACf,CAAC;CACH,CAAC;AAEK,wBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAhBiB,kBAAkB"}
|
|
@@ -7,12 +7,12 @@ class AuthProfilesList extends base_command_1.BaseCommand {
|
|
|
7
7
|
const profileNames = this.configManager.getProfileNames();
|
|
8
8
|
const profiles = profileNames.map((name) => {
|
|
9
9
|
const profile = this.configManager.getProfile(name);
|
|
10
|
-
const
|
|
10
|
+
const loggedIn = this.credentials.get(name) !== undefined;
|
|
11
11
|
return {
|
|
12
12
|
name,
|
|
13
13
|
active: name === activeProfile,
|
|
14
14
|
api_url: profile.api_url,
|
|
15
|
-
|
|
15
|
+
logged_in: loggedIn,
|
|
16
16
|
store_ref: profile.store_ref || null,
|
|
17
17
|
store_name: profile.store_name || null,
|
|
18
18
|
default_output: profile.default_output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/auth/profiles/list.ts"],"names":[],"mappings":";;AAAA,wDAAoD;AAEpD,MAAqB,gBAAiB,SAAQ,0BAAW;IASvD,KAAK,CAAC,GAAG;QACP,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,oBAAoB,EAAE,CAAC;QAChE,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;QAE1D,M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"}
|
|
@@ -3,30 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const base_command_1 = require("../../base-command");
|
|
4
4
|
class AuthStatus extends base_command_1.BaseCommand {
|
|
5
5
|
async run() {
|
|
6
|
-
const profileName = this.
|
|
6
|
+
const profileName = this.profileName;
|
|
7
7
|
const profile = this.configManager.getProfile();
|
|
8
|
+
const fromArgv = (flag) => this.argv.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
8
9
|
const apiKey = this.configManager.resolveApiKey(this.getFlag("api-key"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const session = apiKey ? undefined : this.credentials.get(profileName);
|
|
11
|
+
const credential = apiKey
|
|
12
|
+
? fromArgv("--api-key")
|
|
13
|
+
? "flag-api-key"
|
|
14
|
+
: "env-api-key"
|
|
15
|
+
: session
|
|
16
|
+
? this.credentials.kind
|
|
17
|
+
: null;
|
|
18
|
+
const apiUrlSource = fromArgv("--api-url")
|
|
12
19
|
? "flag --api-url"
|
|
13
20
|
: process.env.ECOMWEB_API_URL !== undefined
|
|
14
21
|
? "env ECOMWEB_API_URL"
|
|
15
22
|
: `profile ${profileName}`;
|
|
16
23
|
this.outputJson({
|
|
17
24
|
profile: profileName,
|
|
25
|
+
logged_in: credential !== null,
|
|
26
|
+
email: session?.email ?? null,
|
|
27
|
+
credential,
|
|
18
28
|
api_url: this.configManager.resolveApiUrl(this.getFlag("api-url")),
|
|
19
29
|
api_url_source: apiUrlSource,
|
|
20
|
-
|
|
21
|
-
api_key_preview: apiKey ? `${apiKey.substring(0, 8)}...${apiKey.substring(apiKey.length - 4)}` : null,
|
|
22
|
-
store_ref: storeRef || null,
|
|
30
|
+
store_ref: this.configManager.resolveStoreRef(this.getFlag("store-ref")) || null,
|
|
23
31
|
store_name: profile.store_name || null,
|
|
24
32
|
default_output: profile.default_output,
|
|
25
33
|
});
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
|
-
AuthStatus.description = "Show
|
|
29
|
-
AuthStatus.examples = ["ecomweb auth status"];
|
|
36
|
+
AuthStatus.description = "Show who you are logged in as, and with what";
|
|
37
|
+
AuthStatus.examples = ["ecomweb auth status", "ecomweb auth status --profile staging"];
|
|
30
38
|
AuthStatus.flags = {
|
|
31
39
|
...base_command_1.BaseCommand.baseFlags,
|
|
32
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAqB,UAAW,SAAQ,0BAAW;IASjD,KAAK,CAAC,GAAG;QACP,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAqB,UAAW,SAAQ,0BAAW;IASjD,KAAK,CAAC,GAAG;QACP,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;QAEhD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,MAAM;YACvB,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACrB,CAAC,CAAC,cAAc;gBAChB,CAAC,CAAC,aAAa;YACjB,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI;gBACvB,CAAC,CAAC,IAAI,CAAC;QACX,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC;YACxC,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,SAAS;gBACzC,CAAC,CAAC,qBAAqB;gBACvB,CAAC,CAAC,WAAW,WAAW,EAAE,CAAC;QAE/B,IAAI,CAAC,UAAU,CAAC;YACd,OAAO,EAAE,WAAW;YACpB,SAAS,EAAE,UAAU,KAAK,IAAI;YAC9B,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;YAC7B,UAAU;YACV,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAClE,cAAc,EAAE,YAAY;YAC5B,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,IAAI;YAChF,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;YACtC,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CAAC;IACL,CAAC;;AAvCM,sBAAW,GAAG,8CAA8C,CAAC;AAE7D,mBAAQ,GAAG,CAAC,qBAAqB,EAAE,uCAAuC,CAAC,CAAC;AAE5E,gBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAPiB,UAAU"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseCommand } from "../../base-command";
|
|
2
|
-
export default class
|
|
2
|
+
export default class StoresCreate extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
"store-ref": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
9
|
"api-key": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
"api-url": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -17,4 +17,5 @@ export default class AuthRegister extends BaseCommand {
|
|
|
17
17
|
exclude: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
18
|
};
|
|
19
19
|
run(): Promise<void>;
|
|
20
|
+
private waitUntilReachable;
|
|
20
21
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const errors_1 = require("../../lib/errors");
|
|
6
|
+
const MEMBERSHIP_WAIT_MS = 5_000;
|
|
7
|
+
class StoresCreate extends base_command_1.BaseCommand {
|
|
8
|
+
async run() {
|
|
9
|
+
const name = this.getFlag("name");
|
|
10
|
+
const description = this.getFlag("description");
|
|
11
|
+
let store;
|
|
12
|
+
try {
|
|
13
|
+
store = await this.apiClient.post("/stores", { name, ...(description && { description }) });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if ((0, errors_1.apiErrorCode)(error) === "ACCESS_DENIED") {
|
|
17
|
+
throw new errors_1.CliError("ACCESS_DENIED", "API keys cannot create stores. Sign in to create a store.", errors_1.ExitCode.AUTH_FAILURE, {
|
|
18
|
+
hint: "Run: ecomweb auth login",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
await this.waitUntilReachable(store.ref);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof errors_1.CliError && error.payload.code === "STORE_NOT_READY")
|
|
28
|
+
throw error;
|
|
29
|
+
const { json } = (0, errors_1.formatError)(error);
|
|
30
|
+
throw new errors_1.CliError("STORE_CREATED_UNCONFIRMED", `The store was created (ref ${store.ref}), but checking it failed: ${json.error.message}`, errors_1.ExitCode.ERROR, {
|
|
31
|
+
hint: `Do not create it again. Run: ecomweb stores switch ${store.ref}`,
|
|
32
|
+
details: { ref: store.ref, name: store.name, created: true, cause: json.error.code },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this.configManager.setStoreRef(store.ref, store.name);
|
|
36
|
+
this.outputJson({ status: "created", store: { ref: store.ref, name: store.name }, profile: this.profileName });
|
|
37
|
+
}
|
|
38
|
+
async waitUntilReachable(ref) {
|
|
39
|
+
const deadline = this.now() + MEMBERSHIP_WAIT_MS;
|
|
40
|
+
for (;;) {
|
|
41
|
+
try {
|
|
42
|
+
await this.apiClient.getStore(ref);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const status = error.response?.status;
|
|
47
|
+
if (status !== 403 && status !== 404)
|
|
48
|
+
throw error;
|
|
49
|
+
if (this.now() >= deadline) {
|
|
50
|
+
throw new errors_1.CliError("STORE_NOT_READY", "The store was created but is not reachable yet", errors_1.ExitCode.ERROR, {
|
|
51
|
+
hint: `Try again in a moment: ecomweb stores switch ${ref}`,
|
|
52
|
+
details: { ref },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
await this.sleep(500);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
StoresCreate.description = "Create a store (you become its owner) and make it the current store";
|
|
61
|
+
StoresCreate.examples = ['ecomweb stores create --name "My Store"', 'ecomweb stores create --name "My Store" --description "Shoes"'];
|
|
62
|
+
StoresCreate.flags = {
|
|
63
|
+
...base_command_1.BaseCommand.baseFlags,
|
|
64
|
+
name: core_1.Flags.string({ description: "Store name (2 to 100 characters)", required: true }),
|
|
65
|
+
description: core_1.Flags.string({ description: "Store description" }),
|
|
66
|
+
};
|
|
67
|
+
exports.default = StoresCreate;
|
|
68
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/stores/create.ts"],"names":[],"mappings":";;AAAA,sCAAoC;AACpC,qDAAiD;AACjD,6CAAiF;AAGjF,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,MAAqB,YAAa,SAAQ,0BAAW;IAWnD,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAS,MAAM,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAS,aAAa,CAAC,CAAC;QAExD,IAAI,KAAoC,CAAC;QACzC,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgC,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7H,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAA,qBAAY,EAAC,KAAK,CAAC,KAAK,eAAe,EAAE,CAAC;gBAC5C,MAAM,IAAI,iBAAQ,CAAC,eAAe,EAAE,2DAA2D,EAAE,iBAAQ,CAAC,YAAY,EAAE;oBACtH,IAAI,EAAE,yBAAyB;iBAChC,CAAC,CAAC;YACL,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,k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,EAAE,CAAC;gBACf,MAAM,MAAM,GAAI,KAA4C,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAC9E,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;oBAAE,MAAM,KAAK,CAAC;gBAClD,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;oBAC3B,MAAM,IAAI,iBAAQ,CAAC,iBAAiB,EAAE,gDAAgD,EAAE,iBAAQ,CAAC,KAAK,EAAE;wBACtG,IAAI,EAAE,gDAAgD,GAAG,EAAE;wBAC3D,OAAO,EAAE,EAAE,GAAG,EAAE;qBACjB,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;;AAhEM,wBAAW,GAAG,qEAAqE,CAAC;AAEpF,qBAAQ,GAAG,CAAC,yCAAyC,EAAE,+DAA+D,CAAC,CAAC;AAExH,kBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;IACxB,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvF,WAAW,EAAE,YAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;CAChE,CAAC;kBATiB,YAAY"}
|
|
@@ -33,7 +33,7 @@ class StoresCurrent extends base_command_1.BaseCommand {
|
|
|
33
33
|
store_ref: storeRef,
|
|
34
34
|
store_name: storeName || null,
|
|
35
35
|
store_name_source: storeName ? source : null,
|
|
36
|
-
profile: this.
|
|
36
|
+
profile: this.profileName,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current.js","sourceRoot":"","sources":["../../../src/commands/stores/current.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAqB,aAAc,SA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,UAAU,CAAC;YACd,SAAS,EAAE,QAAQ;YACnB,UAAU,EAAE,SAAS,IAAI,IAAI;YAC7B,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;YAC5C,OAAO,EAAE,IAAI,CAAC,WAAW;SAC1B,CAAC,CAAC;IACL,CAAC;;AA9CM,yBAAW,GAAG,4EAA4E,CAAC;AAE3F,sBAAQ,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAEtC,mBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAPiB,aAAa"}
|
|
@@ -10,13 +10,13 @@ class StoresList extends base_command_1.BaseCommand {
|
|
|
10
10
|
data: stores,
|
|
11
11
|
available_actions: ["switch", "info"],
|
|
12
12
|
hints: {
|
|
13
|
-
switch: "ecomweb stores switch <
|
|
14
|
-
info: "ecomweb stores info <
|
|
13
|
+
switch: "ecomweb stores switch <ref>",
|
|
14
|
+
info: "ecomweb stores info <ref>",
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
StoresList.description = "List
|
|
19
|
+
StoresList.description = "List the stores you can open";
|
|
20
20
|
StoresList.examples = ["ecomweb stores list"];
|
|
21
21
|
StoresList.flags = {
|
|
22
22
|
...base_command_1.BaseCommand.baseFlags,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/stores/list.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAqB,UAAW,SAAQ,0BAAW;IASjD,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC;YAChB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;YACZ,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;YACrC,KAAK,EAAE;gBACL,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/stores/list.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAqB,UAAW,SAAQ,0BAAW;IASjD,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC;YAChB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;YACZ,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;YACrC,KAAK,EAAE;gBACL,MAAM,EAAE,6BAA6B;gBACrC,IAAI,EAAE,2BAA2B;aAClC;SACF,CAAC,CAAC;IACL,CAAC;;AArBM,sBAAW,GAAG,8BAA8B,CAAC;AAE7C,mBAAQ,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAEnC,gBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAPiB,UAAU"}
|
|
@@ -2,27 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const base_command_1 = require("../../base-command");
|
|
5
|
+
const errors_1 = require("../../lib/errors");
|
|
5
6
|
class StoresSwitch extends base_command_1.BaseCommand {
|
|
6
7
|
async run() {
|
|
7
8
|
const { args } = await this.parse(StoresSwitch);
|
|
8
9
|
const storeRef = args.ref;
|
|
9
|
-
let
|
|
10
|
+
let store;
|
|
10
11
|
try {
|
|
11
|
-
|
|
12
|
-
storeName = store.name || store.store_name;
|
|
12
|
+
store = await this.apiClient.getStore(storeRef);
|
|
13
13
|
}
|
|
14
|
-
catch {
|
|
14
|
+
catch (error) {
|
|
15
|
+
const status = error.response?.status;
|
|
16
|
+
if (status === 403 || status === 404) {
|
|
17
|
+
throw new errors_1.CliError("STORE_NOT_FOUND", `You have no access to store "${storeRef}"`, errors_1.ExitCode.NOT_FOUND, {
|
|
18
|
+
hint: "List your stores: ecomweb stores list",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
15
22
|
}
|
|
23
|
+
const storeName = store?.name || store?.store_name;
|
|
16
24
|
this.configManager.setStoreRef(storeRef, storeName);
|
|
17
25
|
this.outputJson({
|
|
18
26
|
store_ref: storeRef,
|
|
19
27
|
store_name: storeName || null,
|
|
20
28
|
message: `Switched to store ${storeRef}`,
|
|
21
|
-
profile: this.
|
|
29
|
+
profile: this.profileName,
|
|
22
30
|
});
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
|
-
StoresSwitch.description = "Switch the
|
|
33
|
+
StoresSwitch.description = "Switch the current store (checks you can open it; persists to the profile)";
|
|
26
34
|
StoresSwitch.examples = [
|
|
27
35
|
"ecomweb stores switch abc123def456",
|
|
28
36
|
"ecomweb stores switch abc123def456 --profile production",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/stores/switch.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,qDAAiD;
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/commands/stores/switch.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,qDAAiD;AACjD,6CAAsD;AAEtD,MAAqB,YAAa,SAAQ,0BAAW;IAgBnD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC;QAE1B,IAAI,KAAoD,CAAC;QACzD,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAI,KAA4C,CAAC,QAAQ,EAAE,MAAM,CAAC;YAC9E,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,iBAAQ,CAAC,iBAAiB,EAAE,gCAAgC,QAAQ,GAAG,EAAE,iBAAQ,CAAC,SAAS,EAAE;oBACrG,IAAI,EAAE,uCAAuC;iBAC9C,CAAC,CAAC;YACL,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,SAAS,GAAG,KAAK,EAAE,IAAI,IAAI,KAAK,EAAE,UAAU,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAEpD,IAAI,CAAC,UAAU,CAAC;YACd,SAAS,EAAE,QAAQ;YACnB,UAAU,EAAE,SAAS,IAAI,IAAI;YAC7B,OAAO,EAAE,qBAAqB,QAAQ,EAAE;YACxC,OAAO,EAAE,IAAI,CAAC,WAAW;SAC1B,CAAC,CAAC;IACL,CAAC;;AAxCM,wBAAW,GAAG,4EAA4E,CAAC;AAE3F,qBAAQ,GAAG;IAChB,oCAAoC;IACpC,yDAAyD;CAC1D,CAAC;AAEK,iBAAI,GAAG;IACZ,GAAG,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;CAC5E,CAAC;AAEK,kBAAK,GAAG;IACb,GAAG,0BAAW,CAAC,SAAS;CACzB,CAAC;kBAdiB,YAAY"}
|
package/dist/lib/api-client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from "axios";
|
|
2
2
|
import FormData from "form-data";
|
|
3
|
+
import { SessionProvider } from "./session";
|
|
3
4
|
export interface ApiClientOptions {
|
|
4
5
|
baseUrl: string;
|
|
5
6
|
apiKey?: string;
|
|
6
|
-
|
|
7
|
+
session?: SessionProvider;
|
|
7
8
|
timeout?: number;
|
|
8
9
|
}
|
|
9
10
|
export interface PaginatedResponse<T> {
|
|
@@ -19,11 +20,11 @@ export interface PaginatedResponse<T> {
|
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
export declare class ApiClient {
|
|
23
|
+
private readonly options;
|
|
22
24
|
private client;
|
|
23
25
|
private storeRef?;
|
|
24
26
|
constructor(options: ApiClientOptions);
|
|
25
|
-
|
|
26
|
-
clearAuth(): void;
|
|
27
|
+
anonymous(): ApiClient;
|
|
27
28
|
setStoreRef(storeRef: string): void;
|
|
28
29
|
private storePath;
|
|
29
30
|
get<T = any>(path: string, params?: Record<string, any>): Promise<T>;
|
|
@@ -45,6 +46,6 @@ export declare class ApiClient {
|
|
|
45
46
|
listAll<T = any>(path: string, params?: Record<string, any>): Promise<T[]>;
|
|
46
47
|
private paginateAll;
|
|
47
48
|
health(): Promise<any>;
|
|
48
|
-
listStores(): Promise<any[]>;
|
|
49
|
+
listStores(params?: Record<string, any>): Promise<any[]>;
|
|
49
50
|
getStore(ref: string): Promise<any>;
|
|
50
51
|
}
|
package/dist/lib/api-client.js
CHANGED
|
@@ -5,35 +5,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ApiClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
|
+
const session_1 = require("./session");
|
|
8
10
|
class ApiClient {
|
|
9
11
|
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
10
13
|
this.client = axios_1.default.create({
|
|
11
14
|
baseURL: options.baseUrl,
|
|
12
15
|
timeout: options.timeout || 30_000,
|
|
13
16
|
headers: {
|
|
14
17
|
"Content-Type": "application/json",
|
|
15
18
|
...(options.apiKey && { "x-api-key": options.apiKey }),
|
|
16
|
-
...(options.jwtToken && { Authorization: `Bearer ${options.jwtToken}` }),
|
|
17
19
|
},
|
|
18
20
|
});
|
|
21
|
+
this.client.interceptors.request.use(async (config) => {
|
|
22
|
+
const session = this.options.session;
|
|
23
|
+
if (!this.options.apiKey && session?.hasSession() && !config.headers.has("Authorization")) {
|
|
24
|
+
config.headers.set("Authorization", `Bearer ${await session.accessToken()}`);
|
|
25
|
+
}
|
|
26
|
+
return config;
|
|
27
|
+
});
|
|
19
28
|
this.client.interceptors.response.use(undefined, async (error) => {
|
|
20
29
|
const config = error.config;
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
const status = error.response?.status;
|
|
31
|
+
if (config && status === 429 && (config._retryCount ?? 0) < 3) {
|
|
32
|
+
config._retryCount = (config._retryCount || 0) + 1;
|
|
33
|
+
const delay = Math.pow(2, config._retryCount) * 1000;
|
|
34
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
35
|
+
return this.client.request(config);
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
const session = this.options.session;
|
|
38
|
+
if (config && status === 401 && session && !this.options.apiKey) {
|
|
39
|
+
if (!session.hasSession())
|
|
40
|
+
return Promise.reject((0, session_1.notLoggedIn)());
|
|
41
|
+
const replayable = !(config.data instanceof form_data_1.default);
|
|
42
|
+
if (replayable && !config._authRetried) {
|
|
43
|
+
config._authRetried = true;
|
|
44
|
+
config.headers.set("Authorization", `Bearer ${await session.accessToken({ force: true })}`);
|
|
45
|
+
return this.client.request(config);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return Promise.reject(error);
|
|
28
49
|
});
|
|
29
50
|
}
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
delete this.client.defaults.headers.common["x-api-key"];
|
|
33
|
-
}
|
|
34
|
-
clearAuth() {
|
|
35
|
-
delete this.client.defaults.headers.common["Authorization"];
|
|
36
|
-
delete this.client.defaults.headers.common["x-api-key"];
|
|
51
|
+
anonymous() {
|
|
52
|
+
return new ApiClient({ baseUrl: this.options.baseUrl, timeout: this.options.timeout });
|
|
37
53
|
}
|
|
38
54
|
setStoreRef(storeRef) {
|
|
39
55
|
this.storeRef = storeRef;
|
|
@@ -129,8 +145,8 @@ class ApiClient {
|
|
|
129
145
|
async health() {
|
|
130
146
|
return this.get("/health");
|
|
131
147
|
}
|
|
132
|
-
async listStores() {
|
|
133
|
-
const result = await this.get("/stores");
|
|
148
|
+
async listStores(params) {
|
|
149
|
+
const result = await this.get("/stores", params);
|
|
134
150
|
return Array.isArray(result) ? result : result.data || [];
|
|
135
151
|
}
|
|
136
152
|
async getStore(ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAiE;AACjE,0DAAiC;AACjC,uCAAyD;AAwBzD,MAAa,SAAS;IAIpB,YAA6B,OAAyB;QAAzB,YAAO,GAAP,OAAO,CAAkB;QACpD,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,MAAM;YAClC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;aACvD;SACF,CAAC,CAAC;QAKH,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACpD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,M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CAAC,MAAM;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAGD,KAAK,CAAC,UAAU,CAAC,MAA4B;QAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAM,SAAS,EAAE,MAAM,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC;IACpC,CAAC;CACF;AAvMD,8BAuMC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CODEX_SKILL = "---\nname: ecomweb\ndescription: Use when someone wants to start building an ecomweb storefront, or asks how to build their ecomweb store's website with Codex, outside an existing storefront project.\n---\n\n# Starting an ecomweb storefront\n\nAn ecomweb storefront is a Next.js project for one ecomweb store: products,\ncart, checkout and accounts come from ecomweb; the merchant (with Codex) owns\nthe pages and the design.\n\n## Inside a storefront project\n\nIf the current folder has an `.ecomweb.json` file, it already is a storefront\nproject. Follow its `AGENTS.md`, which points to the project's own skill.\n\n## Starting one\n\n1. Check the prerequisites: `node --version` (24 or newer), `pnpm --version`,\n `git --version`. If one is missing, stop and give the install links:\n https://nodejs.org, https://pnpm.io/installation, https://git-scm.com/downloads.\n2. Check the login: `npx @ecomweb/cli auth status`. If
|
|
1
|
+
export declare const CODEX_SKILL = "---\nname: ecomweb\ndescription: Use when someone wants to start building an ecomweb storefront, or asks how to build their ecomweb store's website with Codex, outside an existing storefront project.\n---\n\n# Starting an ecomweb storefront\n\nAn ecomweb storefront is a Next.js project for one ecomweb store: products,\ncart, checkout and accounts come from ecomweb; the merchant (with Codex) owns\nthe pages and the design.\n\n## Inside a storefront project\n\nIf the current folder has an `.ecomweb.json` file, it already is a storefront\nproject. Follow its `AGENTS.md`, which points to the project's own skill.\n\n## Starting one\n\n1. Check the prerequisites: `node --version` (24 or newer), `pnpm --version`,\n `git --version`. If one is missing, stop and give the install links:\n https://nodejs.org, https://pnpm.io/installation, https://git-scm.com/downloads.\n2. Check the login: `npx @ecomweb/cli auth status`. If `logged_in` is false,\n run `npx @ecomweb/cli auth login`. Show the user the\n `verification_uri_complete` link and the `user_code`, and ask them to open\n the link and approve (the code on the page must match). Then run\n `npx @ecomweb/cli auth login --wait`; run it again while it still answers\n `authorization_pending`.\n3. The login picks the store when there is one; if it lists several, ask which\n and run `npx @ecomweb/cli stores switch <ref>`. With none, ask for a name and\n run `npx @ecomweb/cli stores create --name \"<name>\"`.\n `npx @ecomweb/cli stores current` shows the store.\n4. Ask whether to create the project on this machine or as a new GitHub\n repository (add `--github`).\n5. Create it: `npx @ecomweb/cli storefront init`. It\n installs dependencies and prints the next steps.\n6. Tell the user to start `codex` inside the new folder and describe the\n storefront they want; `pnpm dev` shows it at http://localhost:3002.\n\nNever ask for codes, keys or tokens, and never write them into files: the\nuser approves the login in their own browser.\n";
|
|
2
2
|
export declare function codexSkillPath(home: string): string;
|
|
3
3
|
export declare function installCodexSkill(home: string, opts?: {
|
|
4
4
|
force?: boolean;
|
package/dist/lib/codex-skill.js
CHANGED
|
@@ -30,12 +30,16 @@ project. Follow its \`AGENTS.md\`, which points to the project's own skill.
|
|
|
30
30
|
1. Check the prerequisites: \`node --version\` (24 or newer), \`pnpm --version\`,
|
|
31
31
|
\`git --version\`. If one is missing, stop and give the install links:
|
|
32
32
|
https://nodejs.org, https://pnpm.io/installation, https://git-scm.com/downloads.
|
|
33
|
-
2. Check the login: \`npx @ecomweb/cli auth status\`. If
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
2. Check the login: \`npx @ecomweb/cli auth status\`. If \`logged_in\` is false,
|
|
34
|
+
run \`npx @ecomweb/cli auth login\`. Show the user the
|
|
35
|
+
\`verification_uri_complete\` link and the \`user_code\`, and ask them to open
|
|
36
|
+
the link and approve (the code on the page must match). Then run
|
|
37
|
+
\`npx @ecomweb/cli auth login --wait\`; run it again while it still answers
|
|
38
|
+
\`authorization_pending\`.
|
|
39
|
+
3. The login picks the store when there is one; if it lists several, ask which
|
|
40
|
+
and run \`npx @ecomweb/cli stores switch <ref>\`. With none, ask for a name and
|
|
41
|
+
run \`npx @ecomweb/cli stores create --name "<name>"\`.
|
|
42
|
+
\`npx @ecomweb/cli stores current\` shows the store.
|
|
39
43
|
4. Ask whether to create the project on this machine or as a new GitHub
|
|
40
44
|
repository (add \`--github\`).
|
|
41
45
|
5. Create it: \`npx @ecomweb/cli storefront init\`. It
|
|
@@ -43,8 +47,8 @@ project. Follow its \`AGENTS.md\`, which points to the project's own skill.
|
|
|
43
47
|
6. Tell the user to start \`codex\` inside the new folder and describe the
|
|
44
48
|
storefront they want; \`pnpm dev\` shows it at http://localhost:3002.
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
Never ask for codes, keys or tokens, and never write them into files: the
|
|
51
|
+
user approves the login in their own browser.
|
|
48
52
|
`;
|
|
49
53
|
function codexSkillPath(home) {
|
|
50
54
|
return node_path_1.default.join(home, ".agents/skills/ecomweb/SKILL.md");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-skill.js","sourceRoot":"","sources":["../../src/lib/codex-skill.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"codex-skill.js","sourceRoot":"","sources":["../../src/lib/codex-skill.ts"],"names":[],"mappings":";;;;;;AAmDA,wCAEC;AAED,8CAkBC;AAzED,qCAA6E;AAC7E,0DAA6B;AAC7B,qCAA8C;AAOjC,QAAA,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwC1B,CAAC;AAEF,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,mBAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iCAAiC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,iBAAiB,CAC/B,IAAY,EACZ,OAA8C,EAAE;IAEhD,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3C,IAAI,OAAO,KAAK,mBAAW;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QACxE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,iBAAQ,CAAC,cAAc,EAAE,uCAAuC,IAAI,EAAE,EAAE,iBAAQ,CAAC,UAAU,EAAE;gBACrG,IAAI,EAAE,6BAA6B;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAChE,IAAA,mBAAS,EAAC,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,IAAA,uBAAa,EAAC,IAAI,EAAE,mBAAW,CAAC,CAAC;IACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC7C,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -8,39 +8,27 @@ export interface AppConfig {
|
|
|
8
8
|
active_profile: string;
|
|
9
9
|
profiles: Record<string, ProfileConfig>;
|
|
10
10
|
}
|
|
11
|
+
export declare const CREDENTIALS_DIR: string;
|
|
12
|
+
export declare function assertValidProfileName(name: string, source?: "flag" | "config"): void;
|
|
11
13
|
export declare class ConfigManager {
|
|
12
14
|
private config;
|
|
13
|
-
|
|
15
|
+
private readonly selected;
|
|
16
|
+
constructor(selectedProfile?: string);
|
|
14
17
|
private ensureDir;
|
|
15
18
|
private loadConfig;
|
|
16
19
|
save(): void;
|
|
17
20
|
getActiveProfileName(): string;
|
|
21
|
+
getProfileName(): string;
|
|
18
22
|
getProfile(name?: string): ProfileConfig;
|
|
19
23
|
setProfile(name: string, profile: Partial<ProfileConfig>): void;
|
|
20
24
|
setActiveProfile(name: string): void;
|
|
21
25
|
setStoreRef(storeRef: string, storeName?: string, profileName?: string): void;
|
|
22
26
|
getStoreRef(): string | undefined;
|
|
23
|
-
getApiKey(profileName?: string): string | undefined;
|
|
24
|
-
setApiKey(key: string, profileName?: string): void;
|
|
25
|
-
removeApiKey(profileName?: string): void;
|
|
26
|
-
getJwtTokens(profileName?: string): {
|
|
27
|
-
access_token: string;
|
|
28
|
-
refresh_token: string;
|
|
29
|
-
expires_at: number;
|
|
30
|
-
email?: string;
|
|
31
|
-
} | undefined;
|
|
32
|
-
setJwtTokens(tokens: {
|
|
33
|
-
access_token: string;
|
|
34
|
-
refresh_token: string;
|
|
35
|
-
expires_at: number;
|
|
36
|
-
email?: string;
|
|
37
|
-
}, profileName?: string): void;
|
|
38
|
-
removeJwtTokens(profileName?: string): void;
|
|
39
|
-
isJwtExpired(profileName?: string): boolean;
|
|
40
27
|
getProfileNames(): string[];
|
|
41
28
|
deleteProfile(name: string): void;
|
|
42
29
|
resolve<T>(flag: T | undefined, envVar: string, profileValue: T | undefined, defaultValue: T): T;
|
|
43
30
|
resolveApiUrl(flag?: string): string;
|
|
44
31
|
resolveApiKey(flag?: string): string | undefined;
|
|
32
|
+
removeLegacyCredentials(profileName: string): void;
|
|
45
33
|
resolveStoreRef(flag?: string): string | undefined;
|
|
46
34
|
}
|