@revos/cli 0.2.3 → 0.3.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/README.md +42 -4
- package/dist/adapters/oclif/commands/action-runs/get.mjs +1 -1
- package/dist/adapters/oclif/commands/action-runs/list.mjs +1 -1
- package/dist/adapters/oclif/commands/actions/get-input-schema.mjs +2 -2
- package/dist/adapters/oclif/commands/actions/get-params-schema.mjs +2 -2
- package/dist/adapters/oclif/commands/actions/get.mjs +1 -1
- package/dist/adapters/oclif/commands/actions/list.mjs +2 -2
- package/dist/adapters/oclif/commands/ai-instructions/create.mjs +1 -1
- package/dist/adapters/oclif/commands/ai-instructions/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/ai-instructions/get.mjs +1 -1
- package/dist/adapters/oclif/commands/ai-instructions/list.mjs +1 -1
- package/dist/adapters/oclif/commands/ai-instructions/update.mjs +1 -1
- package/dist/adapters/oclif/commands/api.mjs +2 -2
- package/dist/adapters/oclif/commands/apply.d.mts +1 -1
- package/dist/adapters/oclif/commands/apply.mjs +2 -2
- package/dist/adapters/oclif/commands/auth/login.mjs +13 -28
- package/dist/adapters/oclif/commands/auth/logout.mjs +2 -2
- package/dist/adapters/oclif/commands/auth/status.mjs +2 -2
- package/dist/adapters/oclif/commands/connections/create.mjs +1 -1
- package/dist/adapters/oclif/commands/connections/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/connections/get.mjs +1 -1
- package/dist/adapters/oclif/commands/connections/list.mjs +1 -1
- package/dist/adapters/oclif/commands/connections/update.mjs +1 -1
- package/dist/adapters/oclif/commands/cubes/create.mjs +1 -1
- package/dist/adapters/oclif/commands/cubes/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/cubes/get.mjs +1 -1
- package/dist/adapters/oclif/commands/cubes/list.mjs +1 -1
- package/dist/adapters/oclif/commands/cubes/meta.d.mts +6 -0
- package/dist/adapters/oclif/commands/cubes/meta.mjs +45 -0
- package/dist/adapters/oclif/commands/cubes/query.d.mts +6 -0
- package/dist/adapters/oclif/commands/cubes/query.mjs +51 -0
- package/dist/adapters/oclif/commands/cubes/update.mjs +1 -1
- package/dist/adapters/oclif/commands/diff.d.mts +1 -1
- package/dist/adapters/oclif/commands/diff.mjs +2 -2
- package/dist/adapters/oclif/commands/gservice-account-keys/get.mjs +1 -1
- package/dist/adapters/oclif/commands/gservice-account-keys/reveal.mjs +2 -2
- package/dist/adapters/oclif/commands/gservice-accounts/create.mjs +1 -1
- package/dist/adapters/oclif/commands/gservice-accounts/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/gservice-accounts/get.mjs +1 -1
- package/dist/adapters/oclif/commands/gservice-accounts/list.mjs +1 -1
- package/dist/adapters/oclif/commands/init.d.mts +2 -0
- package/dist/adapters/oclif/commands/init.mjs +92 -4
- package/dist/adapters/oclif/commands/org/create.mjs +1 -1
- package/dist/adapters/oclif/commands/org/current.mjs +2 -2
- package/dist/adapters/oclif/commands/org/get.mjs +1 -1
- package/dist/adapters/oclif/commands/org/list.mjs +2 -2
- package/dist/adapters/oclif/commands/org/switch.mjs +2 -2
- package/dist/adapters/oclif/commands/pull.d.mts +1 -1
- package/dist/adapters/oclif/commands/pull.mjs +2 -2
- package/dist/adapters/oclif/commands/score-groups/create.mjs +1 -1
- package/dist/adapters/oclif/commands/score-groups/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/score-groups/get.mjs +1 -1
- package/dist/adapters/oclif/commands/score-groups/list.mjs +1 -1
- package/dist/adapters/oclif/commands/score-groups/update.mjs +1 -1
- package/dist/adapters/oclif/commands/scores/create.mjs +1 -1
- package/dist/adapters/oclif/commands/scores/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/scores/list.mjs +1 -1
- package/dist/adapters/oclif/commands/scores/update.mjs +1 -1
- package/dist/adapters/oclif/commands/segments/create.mjs +1 -1
- package/dist/adapters/oclif/commands/segments/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/segments/evaluate.mjs +2 -2
- package/dist/adapters/oclif/commands/segments/get-evaluation-history.mjs +2 -2
- package/dist/adapters/oclif/commands/segments/get-version.mjs +2 -2
- package/dist/adapters/oclif/commands/segments/get.mjs +1 -1
- package/dist/adapters/oclif/commands/segments/list-versions.mjs +2 -2
- package/dist/adapters/oclif/commands/segments/list.mjs +1 -1
- package/dist/adapters/oclif/commands/segments/restore-version.mjs +2 -2
- package/dist/adapters/oclif/commands/segments/update.mjs +1 -1
- package/dist/adapters/oclif/commands/sources/create.mjs +2 -2
- package/dist/adapters/oclif/commands/sources/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/sources/get.mjs +1 -1
- package/dist/adapters/oclif/commands/sources/list-streams.mjs +2 -2
- package/dist/adapters/oclif/commands/sources/list.mjs +1 -1
- package/dist/adapters/oclif/commands/sources/update.mjs +2 -2
- package/dist/adapters/oclif/commands/status.d.mts +1 -1
- package/dist/adapters/oclif/commands/status.mjs +3 -3
- package/dist/adapters/oclif/commands/table-views/create.mjs +1 -1
- package/dist/adapters/oclif/commands/table-views/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/table-views/list.mjs +1 -1
- package/dist/adapters/oclif/commands/table-views/update.mjs +1 -1
- package/dist/adapters/oclif/commands/tables/create.mjs +1 -1
- package/dist/adapters/oclif/commands/tables/delete.mjs +1 -1
- package/dist/adapters/oclif/commands/tables/get.mjs +1 -1
- package/dist/adapters/oclif/commands/tables/list.mjs +1 -1
- package/dist/adapters/oclif/commands/tables/update.mjs +1 -1
- package/dist/{base.command-D8taHOFF.mjs → base.command-CnVb4RG6.mjs} +1 -1
- package/dist/{core-B-IdeRNl.mjs → core-CY9pC37x.mjs} +68 -5
- package/dist/{factory-CCcimDhl.mjs → factory-DTqayaCF.mjs} +2 -2
- package/dist/{index-D0ax2I61.d.mts → index-Cbb9pLt6.d.mts} +26 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{presets-Bb9gwgeh.mjs → presets-mJzFGMhG.mjs} +2 -2
- package/dist/templates/.devcontainer/Dockerfile +8 -0
- package/dist/templates/.devcontainer/devcontainer.json +10 -9
- package/dist/templates/.devcontainer/post-create.sh +46 -0
- package/dist/templates/.devcontainer/post-start.sh +61 -0
- package/dist/templates/.devcontainer/welcome.sh +26 -0
- package/dist/templates/README.md +80 -12
- package/package.json +1 -1
- package/dist/templates/.devcontainer/setup.sh +0 -35
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { E as getConfig,
|
|
1
|
+
import { D as resolveApiUrl, E as getConfig, G as ApiError, O as performOAuthLogin, U as loadCredentials, l as resolveProjectContext, t as InitService } from "../../../core-CY9pC37x.mjs";
|
|
2
2
|
import { TEMPLATES_DIR } from "../../../templates/index.mjs";
|
|
3
|
-
import { t as BaseCommand } from "../../../base.command-
|
|
3
|
+
import { t as BaseCommand } from "../../../base.command-CnVb4RG6.mjs";
|
|
4
4
|
import * as fs from "fs";
|
|
5
5
|
import * as path from "path";
|
|
6
6
|
import chalk from "chalk";
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
7
8
|
import { Args, Flags } from "@oclif/core";
|
|
8
9
|
import select from "@inquirer/select";
|
|
9
10
|
//#region src/adapters/oclif/commands/init.ts
|
|
@@ -33,8 +34,28 @@ var Init = class extends BaseCommand {
|
|
|
33
34
|
})
|
|
34
35
|
};
|
|
35
36
|
async run() {
|
|
36
|
-
const { apiUrl, token, organizationId } = await getConfig();
|
|
37
37
|
const projectDir = this.args.destination ? path.resolve(this.args.destination) : process.cwd();
|
|
38
|
+
const service = new InitService(TEMPLATES_DIR);
|
|
39
|
+
const projectCtx = fs.existsSync(projectDir) ? resolveProjectContext({ cwd: projectDir }) : null;
|
|
40
|
+
if (projectCtx && !this.flags["dry-run"] && !loadCredentials()) {
|
|
41
|
+
this.log("Not authenticated. Opening browser to sign in...\n");
|
|
42
|
+
const { userInfo } = await performOAuthLogin({
|
|
43
|
+
apiUrl: resolveApiUrl(),
|
|
44
|
+
organizationId: projectCtx.orgId,
|
|
45
|
+
log: (msg) => this.log(msg)
|
|
46
|
+
});
|
|
47
|
+
this.log(chalk.green(`\nAuthenticated as ${userInfo.email || userInfo.sub}`));
|
|
48
|
+
}
|
|
49
|
+
const { apiUrl, token, organizationId } = await getConfig();
|
|
50
|
+
if (projectCtx) {
|
|
51
|
+
await this.runInProject({
|
|
52
|
+
apiUrl,
|
|
53
|
+
token,
|
|
54
|
+
service,
|
|
55
|
+
projectCtx
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
38
59
|
if (fs.existsSync(projectDir) && !isDirEmpty(projectDir) && !this.flags.yes) {
|
|
39
60
|
if (await select({
|
|
40
61
|
message: `Directory "${path.basename(projectDir)}" already exists and is not empty. What would you like to do?`,
|
|
@@ -50,7 +71,6 @@ var Init = class extends BaseCommand {
|
|
|
50
71
|
return;
|
|
51
72
|
}
|
|
52
73
|
}
|
|
53
|
-
const service = new InitService(TEMPLATES_DIR);
|
|
54
74
|
const org = await service.resolveOrganization(apiUrl, token, organizationId).catch((err) => {
|
|
55
75
|
const message = err instanceof Error ? err.message : String(err);
|
|
56
76
|
this.error(message, { exit: 1 });
|
|
@@ -102,6 +122,74 @@ var Init = class extends BaseCommand {
|
|
|
102
122
|
this.log(`\nNext step: open ${chalk.bold(result.projectDir)} in VS Code and click ${chalk.bold("Reopen in Container")}.`);
|
|
103
123
|
this.log(`\n${chalk.dim("Tip: once inside the Dev Container, ask Claude to \"load sample data\" if you need example datasets.")}\n`);
|
|
104
124
|
}
|
|
125
|
+
async runInProject(args) {
|
|
126
|
+
const { apiUrl, token, service, projectCtx } = args;
|
|
127
|
+
const projectSlug = projectCtx.projectFile.metadata.name;
|
|
128
|
+
const orgId = projectCtx.orgId;
|
|
129
|
+
if (!projectSlug) this.error(`revos.yaml at ${projectCtx.projectFile.path} is missing metadata.name — required to locate the GCP service account key.`, { exit: 1 });
|
|
130
|
+
if (this.flags["dry-run"]) {
|
|
131
|
+
this.log(`\nDetected existing RevOS project at ${chalk.dim(projectCtx.projectPath)}`);
|
|
132
|
+
this.log(` Org: ${chalk.bold(orgId)}`);
|
|
133
|
+
const keyPath = InitService.gcpKeyPath(projectSlug);
|
|
134
|
+
if (fs.existsSync(keyPath) && fs.statSync(keyPath).size > 0) this.log(chalk.dim("\nNothing to do — GCP service account key already present."));
|
|
135
|
+
else this.log(`\nWould provision GCP service account key at ${keyPath}`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const org = await service.resolveOrganization(apiUrl, token, orgId).catch((err) => {
|
|
139
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
140
|
+
this.error(message, { exit: 1 });
|
|
141
|
+
});
|
|
142
|
+
this.log(`\nDetected existing RevOS project at ${chalk.dim(projectCtx.projectPath)}`);
|
|
143
|
+
this.log(` Org: ${chalk.bold(org.name)} (${org.id})\n`);
|
|
144
|
+
const result = await service.ensureGcpKey({
|
|
145
|
+
apiUrl,
|
|
146
|
+
token,
|
|
147
|
+
organization: org,
|
|
148
|
+
projectSlug
|
|
149
|
+
}).catch((err) => {
|
|
150
|
+
if (err instanceof ApiError) {
|
|
151
|
+
this.log(chalk.red(`\nAPI error: ${err.status} ${err.statusText}`));
|
|
152
|
+
this.log(chalk.red(`URL: ${err.url}`));
|
|
153
|
+
this.log(chalk.red(`Body: ${JSON.stringify(err.body, null, 2)}`));
|
|
154
|
+
}
|
|
155
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
156
|
+
this.error(message, { exit: 1 });
|
|
157
|
+
});
|
|
158
|
+
if (result.status === "created") {
|
|
159
|
+
this.log(chalk.green(`Provisioned GCP service account key: ${result.keyPath}`));
|
|
160
|
+
this.activateGcloudInContainer(result.keyPath);
|
|
161
|
+
} else this.log(chalk.dim(`Nothing to do — GCP service account key already present at ${result.keyPath}.`));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* After provisioning a key inside a Dev Container, the GSA still needs to
|
|
165
|
+
* be activated in gcloud's local config for `bq`, `dbt`, and direct
|
|
166
|
+
* `gcloud` commands to work in this shell — postStartCommand already ran
|
|
167
|
+
* with no key file. We do that activation here, but only inside a
|
|
168
|
+
* container (detected via /.dockerenv) so we never touch the user's
|
|
169
|
+
* personal gcloud config on the host.
|
|
170
|
+
*/
|
|
171
|
+
activateGcloudInContainer(keyPath) {
|
|
172
|
+
if (!fs.existsSync("/.dockerenv")) return;
|
|
173
|
+
try {
|
|
174
|
+
execFileSync("gcloud", [
|
|
175
|
+
"auth",
|
|
176
|
+
"activate-service-account",
|
|
177
|
+
"--key-file",
|
|
178
|
+
keyPath
|
|
179
|
+
], { stdio: "ignore" });
|
|
180
|
+
const project = process.env.GOOGLE_CLOUD_PROJECT;
|
|
181
|
+
if (project) execFileSync("gcloud", [
|
|
182
|
+
"config",
|
|
183
|
+
"set",
|
|
184
|
+
"project",
|
|
185
|
+
project
|
|
186
|
+
], { stdio: "ignore" });
|
|
187
|
+
this.log(chalk.green("Activated service account in gcloud."));
|
|
188
|
+
} catch (err) {
|
|
189
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
190
|
+
this.log(chalk.yellow(`Could not activate gcloud automatically (${msg}). Run manually:\n gcloud auth activate-service-account --key-file=${keyPath}`));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
105
193
|
};
|
|
106
194
|
//#endregion
|
|
107
195
|
export { Init as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig,
|
|
2
|
-
import { t as BaseCommand } from "../../../../base.command-
|
|
1
|
+
import { E as getConfig, U as loadCredentials, b as createApiClient, l as resolveProjectContext, x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../../base.command-CnVb4RG6.mjs";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
//#region src/adapters/oclif/commands/org/current.ts
|
|
5
5
|
var OrgCurrent = class extends BaseCommand {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as resolveProjectContext, x as unwrap } from "../../../../core-
|
|
2
|
-
import { a as resolveColumns, i as renderList, r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { l as resolveProjectContext, x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { a as resolveColumns, i as renderList, r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { Flags } from "@oclif/core";
|
|
5
5
|
//#region src/adapters/oclif/commands/org/list.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig,
|
|
2
|
-
import { t as BaseCommand } from "../../../../base.command-
|
|
1
|
+
import { E as getConfig, U as loadCredentials, W as saveCredentials, a as formatInProjectSwitchWarning, b as createApiClient, l as resolveProjectContext, n as selectOrganization, x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../../base.command-CnVb4RG6.mjs";
|
|
3
3
|
import * as os from "os";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { Args } from "@oclif/core";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as PulledResource } from "../../../index-
|
|
1
|
+
import { d as PulledResource } from "../../../index-Cbb9pLt6.mjs";
|
|
2
2
|
import { c as IacError } from "../../../context-D5uelKLe.mjs";
|
|
3
3
|
import { t as BaseCommand } from "../../../base.command-BmddDbHa.mjs";
|
|
4
4
|
import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig, _ as buildIacRegistry, b as createApiClient, p as pull, v as discoverProject, y as projectRoot } from "../../../core-
|
|
2
|
-
import { t as BaseCommand } from "../../../base.command-
|
|
1
|
+
import { E as getConfig, _ as buildIacRegistry, b as createApiClient, p as pull, v as discoverProject, y as projectRoot } from "../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../base.command-CnVb4RG6.mjs";
|
|
3
3
|
import { n as renderIacErrors } from "../../../iac-render-BSZZEP0n.mjs";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { Args, Flags } from "@oclif/core";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCommand } from "../../../../presets-
|
|
1
|
+
import { t as createCommand } from "../../../../presets-mJzFGMhG.mjs";
|
|
2
2
|
//#region src/adapters/oclif/commands/score-groups/create.ts
|
|
3
3
|
var create_default = createCommand({
|
|
4
4
|
resource: "scoreGroups",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as deleteCommand } from "../../../../presets-
|
|
1
|
+
import { n as deleteCommand } from "../../../../presets-mJzFGMhG.mjs";
|
|
2
2
|
//#region src/adapters/oclif/commands/score-groups/delete.ts
|
|
3
3
|
var delete_default = deleteCommand({
|
|
4
4
|
resource: "scoreGroups",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as updateCommand } from "../../../../presets-
|
|
1
|
+
import { a as updateCommand } from "../../../../presets-mJzFGMhG.mjs";
|
|
2
2
|
//#region src/adapters/oclif/commands/score-groups/update.ts
|
|
3
3
|
var update_default = updateCommand({
|
|
4
4
|
resource: "scoreGroups",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
//#region src/adapters/oclif/commands/segments/evaluate.ts
|
|
5
5
|
var evaluate_default = defineApiCommand({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
//#region src/adapters/oclif/commands/segments/get-evaluation-history.ts
|
|
5
5
|
var get_evaluation_history_default = defineApiCommand({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
//#region src/adapters/oclif/commands/segments/get-version.ts
|
|
5
5
|
var get_version_default = defineApiCommand({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { n as createListRender, r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { n as createListRender, r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args, Flags } from "@oclif/core";
|
|
4
4
|
var list_versions_default = defineApiCommand({
|
|
5
5
|
description: "List versions of a segment",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
//#region src/adapters/oclif/commands/segments/restore-version.ts
|
|
5
5
|
var restore_version_default = defineApiCommand({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig, S as resolveAppUrl } from "../../../../core-
|
|
2
|
-
import { t as BaseCommand } from "../../../../base.command-
|
|
1
|
+
import { E as getConfig, S as resolveAppUrl } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../../base.command-CnVb4RG6.mjs";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import open from "open";
|
|
5
5
|
//#region src/adapters/oclif/commands/sources/create.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { x as unwrap } from "../../../../core-
|
|
2
|
-
import { n as createListRender, r as defineApiCommand } from "../../../../factory-
|
|
1
|
+
import { x as unwrap } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { n as createListRender, r as defineApiCommand } from "../../../../factory-DTqayaCF.mjs";
|
|
3
3
|
import { Args, Flags } from "@oclif/core";
|
|
4
4
|
var list_streams_default = defineApiCommand({
|
|
5
5
|
description: "List streams the source exposes (sync modes, cursor/PK candidates, field paths)",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig, S as resolveAppUrl } from "../../../../core-
|
|
2
|
-
import { t as BaseCommand } from "../../../../base.command-
|
|
1
|
+
import { E as getConfig, S as resolveAppUrl } from "../../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../../base.command-CnVb4RG6.mjs";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { Args } from "@oclif/core";
|
|
5
5
|
import open from "open";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as ResourceStatus } from "../../../index-
|
|
1
|
+
import { u as ResourceStatus } from "../../../index-Cbb9pLt6.mjs";
|
|
2
2
|
import { c as IacError } from "../../../context-D5uelKLe.mjs";
|
|
3
3
|
import { t as BaseCommand } from "../../../base.command-BmddDbHa.mjs";
|
|
4
4
|
import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as buildIacRegistry, b as createApiClient, f as describeResources, g as loadResources, v as discoverProject, y as projectRoot } from "../../../core-
|
|
2
|
-
import { t as BaseCommand } from "../../../base.command-
|
|
3
|
-
import { a as resolveColumns, i as renderList } from "../../../factory-
|
|
1
|
+
import { _ as buildIacRegistry, b as createApiClient, f as describeResources, g as loadResources, v as discoverProject, y as projectRoot } from "../../../core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "../../../base.command-CnVb4RG6.mjs";
|
|
3
|
+
import { a as resolveColumns, i as renderList } from "../../../factory-DTqayaCF.mjs";
|
|
4
4
|
import { n as renderIacErrors } from "../../../iac-render-BSZZEP0n.mjs";
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import { Args, Flags } from "@oclif/core";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as ApiError, I as setAuthConfig, U as loadCredentials, i as formatEnvMismatchError, l as resolveProjectContext, o as formatProjectOrgFlagError, r as formatCredentialsMismatchWarning, u as validateEnvAgainstProject } from "./core-CY9pC37x.mjs";
|
|
2
2
|
import { Command, Flags } from "@oclif/core";
|
|
3
3
|
import { makeTable } from "@oclif/table";
|
|
4
4
|
//#region src/adapters/oclif/base.command.ts
|
|
@@ -357,8 +357,43 @@ async function refreshAccessToken(refreshToken) {
|
|
|
357
357
|
return response.json();
|
|
358
358
|
}
|
|
359
359
|
//#endregion
|
|
360
|
+
//#region src/core/auth/oauth-flow.ts
|
|
361
|
+
const noop = () => {};
|
|
362
|
+
async function performOAuthLogin(opts) {
|
|
363
|
+
const log = opts.log ?? noop;
|
|
364
|
+
const server = await startOAuthServer();
|
|
365
|
+
const redirectUri = `http://localhost:${server.port}/callback`;
|
|
366
|
+
const pkce = generatePKCEChallenge();
|
|
367
|
+
const authorizationUrl = buildAuthorizationUrl(redirectUri, pkce);
|
|
368
|
+
log("Opening browser for authentication...");
|
|
369
|
+
log("If the browser doesn't open, visit this URL:\n");
|
|
370
|
+
log(` ${authorizationUrl}\n`);
|
|
371
|
+
log("Waiting for authentication... (Press Ctrl+C to cancel)\n");
|
|
372
|
+
const { default: open } = await import("open");
|
|
373
|
+
await open(authorizationUrl);
|
|
374
|
+
const callbackResult = await server.waitForCallback();
|
|
375
|
+
if (callbackResult.state !== pkce.state) throw new Error("Invalid state parameter. Authentication may have been tampered with.");
|
|
376
|
+
log("Received authorization code, exchanging for tokens...\n");
|
|
377
|
+
const tokenResponse = await exchangeCodeForTokens(callbackResult.code, redirectUri, pkce.codeVerifier);
|
|
378
|
+
const userInfo = await getUserInfo(tokenResponse.access_token);
|
|
379
|
+
const credentials = tokenResponseToCredentials(tokenResponse, userInfo);
|
|
380
|
+
const activeAuth = getActiveAuthConfig();
|
|
381
|
+
credentials.apiUrl = opts.apiUrl;
|
|
382
|
+
credentials.authUrl = activeAuth.authUrl;
|
|
383
|
+
credentials.authClientId = activeAuth.authClientId;
|
|
384
|
+
if (opts.organizationId) credentials.organizationId = opts.organizationId;
|
|
385
|
+
saveCredentials(credentials);
|
|
386
|
+
return {
|
|
387
|
+
credentials,
|
|
388
|
+
userInfo
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
//#endregion
|
|
360
392
|
//#region src/core/config.ts
|
|
361
393
|
const DEFAULT_API_URL = "https://api.revos.ai";
|
|
394
|
+
function resolveApiUrl() {
|
|
395
|
+
return process.env.REVOS_API_URL || "https://api.revos.ai";
|
|
396
|
+
}
|
|
362
397
|
async function getStoredAccessToken() {
|
|
363
398
|
const credentials = loadCredentials();
|
|
364
399
|
if (!credentials) return null;
|
|
@@ -381,7 +416,7 @@ async function getConfig() {
|
|
|
381
416
|
const token = process.env.REVOS_TOKEN || await getStoredAccessToken();
|
|
382
417
|
if (!token) throw new Error("Not authenticated. Run 'revos auth login' or set REVOS_TOKEN environment variable.");
|
|
383
418
|
return {
|
|
384
|
-
apiUrl:
|
|
419
|
+
apiUrl: resolveApiUrl(),
|
|
385
420
|
token,
|
|
386
421
|
organizationId: process.env.REVOS_ORG_ID || getStoredOrganizationId()
|
|
387
422
|
};
|
|
@@ -2230,7 +2265,9 @@ var InitService = class InitService {
|
|
|
2230
2265
|
"revos.yaml",
|
|
2231
2266
|
".devcontainer/devcontainer.json",
|
|
2232
2267
|
".devcontainer/Dockerfile",
|
|
2233
|
-
".devcontainer/
|
|
2268
|
+
".devcontainer/post-create.sh",
|
|
2269
|
+
".devcontainer/post-start.sh",
|
|
2270
|
+
".devcontainer/welcome.sh",
|
|
2234
2271
|
".gitignore",
|
|
2235
2272
|
"README.md",
|
|
2236
2273
|
"dbt/profiles.yml",
|
|
@@ -2336,6 +2373,26 @@ var InitService = class InitService {
|
|
|
2336
2373
|
if (!full.bqDataset) throw new Error("Organization is missing BigQuery dataset configuration. Contact support.");
|
|
2337
2374
|
return full;
|
|
2338
2375
|
}
|
|
2376
|
+
static gcpKeyPath(projectSlug) {
|
|
2377
|
+
return path.join(os.homedir(), ".revos", `${projectSlug}-gsa-creds.json`);
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Idempotent GSA provisioning entrypoint for in-project re-runs of
|
|
2381
|
+
* `revos init`. Provisions and writes the key only when the local file is
|
|
2382
|
+
* missing; otherwise reports "exists" without touching the API.
|
|
2383
|
+
*/
|
|
2384
|
+
async ensureGcpKey(options) {
|
|
2385
|
+
const keyPath = InitService.gcpKeyPath(options.projectSlug);
|
|
2386
|
+
if (fs.existsSync(keyPath) && fs.statSync(keyPath).size > 0) return {
|
|
2387
|
+
keyPath,
|
|
2388
|
+
status: "exists"
|
|
2389
|
+
};
|
|
2390
|
+
await this.downloadGcpKey(options.apiUrl, options.token, options.organization, options.projectSlug);
|
|
2391
|
+
return {
|
|
2392
|
+
keyPath,
|
|
2393
|
+
status: "created"
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2339
2396
|
async downloadGcpKey(apiUrl, token, org, projectSlug) {
|
|
2340
2397
|
const api = createApiClient({
|
|
2341
2398
|
apiUrl,
|
|
@@ -2346,7 +2403,7 @@ var InitService = class InitService {
|
|
|
2346
2403
|
if (!keyId) throw new Error("Service account has no keys");
|
|
2347
2404
|
const keyJson = unwrap(await api.gserviceAccountKeys.reveal({ id: keyId }))?.key;
|
|
2348
2405
|
if (!keyJson) throw new Error("Service account key is empty");
|
|
2349
|
-
const gcpKeyPath =
|
|
2406
|
+
const gcpKeyPath = InitService.gcpKeyPath(projectSlug);
|
|
2350
2407
|
fs.mkdirSync(path.dirname(gcpKeyPath), { recursive: true });
|
|
2351
2408
|
fs.writeFileSync(gcpKeyPath, keyJson, process.platform !== "win32" ? {
|
|
2352
2409
|
encoding: "utf-8",
|
|
@@ -2377,10 +2434,16 @@ var InitService = class InitService {
|
|
|
2377
2434
|
organizationId: org.id
|
|
2378
2435
|
}),
|
|
2379
2436
|
".devcontainer/Dockerfile": this.renderTemplate(".devcontainer/Dockerfile", {}),
|
|
2380
|
-
".devcontainer/
|
|
2437
|
+
".devcontainer/post-create.sh": this.renderTemplate(".devcontainer/post-create.sh", {}),
|
|
2438
|
+
".devcontainer/post-start.sh": this.renderTemplate(".devcontainer/post-start.sh", { projectSlug }),
|
|
2439
|
+
".devcontainer/welcome.sh": this.renderTemplate(".devcontainer/welcome.sh", {
|
|
2440
|
+
projectName,
|
|
2441
|
+
projectSlug
|
|
2442
|
+
}),
|
|
2381
2443
|
".gitignore": this.renderTemplate("gitignore", {}),
|
|
2382
2444
|
"README.md": this.renderTemplate("README.md", {
|
|
2383
2445
|
projectName,
|
|
2446
|
+
projectSlug,
|
|
2384
2447
|
orgName: org.name
|
|
2385
2448
|
}),
|
|
2386
2449
|
"dbt/profiles.yml": this.renderTemplate("dbt/profiles.yml", { bqLocation: org.bqLocation ?? "europe-west3" }),
|
|
@@ -2445,4 +2508,4 @@ var InitService = class InitService {
|
|
|
2445
2508
|
}
|
|
2446
2509
|
};
|
|
2447
2510
|
//#endregion
|
|
2448
|
-
export {
|
|
2511
|
+
export { buildAuthorizationUrl as A, deleteCredentials as B, formatError as C, resolveApiUrl as D, getConfig as E, refreshAccessToken as F, ApiError as G, isTokenExpired as H, setAuthConfig as I, setAuthEnv as L, generatePKCEChallenge as M, getActiveAuthConfig as N, performOAuthLogin as O, getUserInfo as P, tokenResponseToCredentials as R, resolveAppUrl as S, DEFAULT_API_URL as T, loadCredentials as U, getCredentialsPath as V, saveCredentials as W, buildIacRegistry as _, formatInProjectSwitchWarning as a, createApiClient as b, isInsideProject as c, iac_exports as d, describeResources as f, loadResources as g, formatDiffLine as h, formatEnvMismatchError as i, exchangeCodeForTokens as j, AUTH_ENVS as k, resolveProjectContext as l, apply as m, selectOrganization as n, formatProjectOrgFlagError as o, pull as p, formatCredentialsMismatchWarning as r, renderProjectContextLine as s, InitService as t, validateEnvAgainstProject as u, discoverProject as v, sanitizeFileName as w, unwrap as x, projectRoot as y, startOAuthServer as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as getConfig, b as createApiClient } from "./core-
|
|
2
|
-
import { t as BaseCommand } from "./base.command-
|
|
1
|
+
import { E as getConfig, b as createApiClient } from "./core-CY9pC37x.mjs";
|
|
2
|
+
import { t as BaseCommand } from "./base.command-CnVb4RG6.mjs";
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import chalk from "chalk";
|