@vaharoni/devops 1.2.7 → 1.2.8
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/cli/common.js +2 -2
- package/dist/cli/core/env.js +2 -2
- package/dist/libs/discovery/index.d.ts +1 -0
- package/dist/libs/discovery/index.d.ts.map +1 -1
- package/dist/libs/discovery/index.js +10 -0
- package/package.json +1 -1
- package/src/cli/common.ts +2 -2
- package/src/cli/core/env.ts +2 -2
- package/src/libs/discovery/index.ts +14 -0
package/dist/cli/common.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { execSync, spawn } from "child_process";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { globSync } from "glob";
|
|
5
4
|
import { allSupportedEnvs } from "../libs/k8s-constants";
|
|
5
|
+
import { globEnvYamlFiles } from "../libs/discovery";
|
|
6
6
|
export class CLICommandParser {
|
|
7
7
|
command;
|
|
8
8
|
args;
|
|
@@ -207,7 +207,7 @@ export class CommandExecutor {
|
|
|
207
207
|
_checkEnvYamlFiles() {
|
|
208
208
|
if (!this.checkEnvYaml)
|
|
209
209
|
return;
|
|
210
|
-
const envYamlFiles =
|
|
210
|
+
const envYamlFiles = globEnvYamlFiles();
|
|
211
211
|
const checkEnvCmd = new CommandExecutor(`devops env _validate ${envYamlFiles.join(" ")}`, { env: this.env, quiet: true, checkEnvYaml: false });
|
|
212
212
|
checkEnvCmd.exec();
|
|
213
213
|
}
|
package/dist/cli/core/env.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globSync } from "glob";
|
|
2
1
|
import { deleteMonorepoSecret, getMonorepoSecretStr, setMonorepoSecret, } from "../../libs/k8s-secrets-manager";
|
|
3
2
|
import { CombinedEnvValidator } from "../../libs/validate-env";
|
|
3
|
+
import { globEnvYamlFiles } from "../../libs/discovery";
|
|
4
4
|
import { CLICommandParser, dotEnvFilesForEnv, printUsageAndExit, } from "../common";
|
|
5
5
|
const oneLiner = "Commands to manipulate env variables";
|
|
6
6
|
const keyExamples = `
|
|
@@ -28,7 +28,7 @@ function run(cmdObj) {
|
|
|
28
28
|
const [command, ...rest] = cmdObj.args;
|
|
29
29
|
switch (command) {
|
|
30
30
|
case "validate": {
|
|
31
|
-
const envYamlFiles =
|
|
31
|
+
const envYamlFiles = globEnvYamlFiles();
|
|
32
32
|
// We have to have a _validate so that we go through a CommandExecutor which injects env variables into the process
|
|
33
33
|
cmdObj
|
|
34
34
|
.executorFromEnv(`devops env _validate ${envYamlFiles.join(" ")}`, { quiet: false })
|
|
@@ -2,4 +2,5 @@ import type { SupportedLanguages, WorkspaceIndex } from "../../types";
|
|
|
2
2
|
export declare function workspaces(): WorkspaceIndex;
|
|
3
3
|
export declare function workspaceDirectoryForLanguage(language: SupportedLanguages): Record<string, import("../..").PackageData>;
|
|
4
4
|
export declare function getWorkspace(workspaceName: string): import("../..").WorkspaceIndexEntry;
|
|
5
|
+
export declare function globEnvYamlFiles(): string[];
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAOtE,wBAAgB,UAAU,mBA8BzB;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,+CASzE;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,uCAQjD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAQ3C"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import { globSync } from "glob";
|
|
3
|
+
import path from "path";
|
|
2
4
|
import { nodeWorkspaces } from "./process-package-json";
|
|
3
5
|
import { pythonWorkspaces } from "./process-pyproject-toml";
|
|
6
|
+
const rootPath = process.env.MONOREPO_ROOT || process.cwd();
|
|
4
7
|
const _workspaces = {};
|
|
5
8
|
let _workspacesLoaded = false;
|
|
6
9
|
export function workspaces() {
|
|
@@ -53,3 +56,10 @@ export function getWorkspace(workspaceName) {
|
|
|
53
56
|
}
|
|
54
57
|
return workspace;
|
|
55
58
|
}
|
|
59
|
+
export function globEnvYamlFiles() {
|
|
60
|
+
const allWorkspaces = workspaces();
|
|
61
|
+
const workspacePaths = [
|
|
62
|
+
...new Set(Object.values(allWorkspaces).map((w) => w.rootPath)),
|
|
63
|
+
];
|
|
64
|
+
return workspacePaths.flatMap((wsPath) => globSync(path.join(rootPath, wsPath, "**/env.yaml")));
|
|
65
|
+
}
|
package/package.json
CHANGED
package/src/cli/common.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { execSync, spawn, type StdioOptions } from "child_process";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { globSync } from "glob";
|
|
5
4
|
import { allSupportedEnvs } from "../libs/k8s-constants";
|
|
5
|
+
import { globEnvYamlFiles } from "../libs/discovery";
|
|
6
6
|
|
|
7
7
|
type ParsedArgs<TBoolKeys extends readonly string[], TParamKeys extends readonly string[]> = {
|
|
8
8
|
args: string[];
|
|
@@ -294,7 +294,7 @@ export class CommandExecutor {
|
|
|
294
294
|
|
|
295
295
|
_checkEnvYamlFiles() {
|
|
296
296
|
if (!this.checkEnvYaml) return;
|
|
297
|
-
const envYamlFiles =
|
|
297
|
+
const envYamlFiles = globEnvYamlFiles();
|
|
298
298
|
const checkEnvCmd = new CommandExecutor(
|
|
299
299
|
`devops env _validate ${envYamlFiles.join(" ")}`,
|
|
300
300
|
{ env: this.env, quiet: true, checkEnvYaml: false }
|
package/src/cli/core/env.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { globSync } from "glob";
|
|
2
1
|
import {
|
|
3
2
|
deleteMonorepoSecret,
|
|
4
3
|
getMonorepoSecretStr,
|
|
5
4
|
setMonorepoSecret,
|
|
6
5
|
} from "../../libs/k8s-secrets-manager";
|
|
7
6
|
import { CombinedEnvValidator } from "../../libs/validate-env";
|
|
7
|
+
import { globEnvYamlFiles } from "../../libs/discovery";
|
|
8
8
|
import {
|
|
9
9
|
CLICommandParser,
|
|
10
10
|
dotEnvFilesForEnv,
|
|
@@ -38,7 +38,7 @@ function run(cmdObj: CLICommandParser) {
|
|
|
38
38
|
const [command, ...rest] = cmdObj.args;
|
|
39
39
|
switch (command) {
|
|
40
40
|
case "validate": {
|
|
41
|
-
const envYamlFiles =
|
|
41
|
+
const envYamlFiles = globEnvYamlFiles();
|
|
42
42
|
|
|
43
43
|
// We have to have a _validate so that we go through a CommandExecutor which injects env variables into the process
|
|
44
44
|
cmdObj
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import { globSync } from "glob";
|
|
3
|
+
import path from "path";
|
|
2
4
|
import { nodeWorkspaces } from "./process-package-json";
|
|
3
5
|
import { pythonWorkspaces } from "./process-pyproject-toml";
|
|
4
6
|
import type { SupportedLanguages, WorkspaceIndex } from "../../types";
|
|
5
7
|
|
|
8
|
+
const rootPath = process.env.MONOREPO_ROOT || process.cwd();
|
|
9
|
+
|
|
6
10
|
const _workspaces: WorkspaceIndex = {};
|
|
7
11
|
let _workspacesLoaded = false;
|
|
8
12
|
|
|
@@ -58,3 +62,13 @@ export function getWorkspace(workspaceName: string) {
|
|
|
58
62
|
}
|
|
59
63
|
return workspace;
|
|
60
64
|
}
|
|
65
|
+
|
|
66
|
+
export function globEnvYamlFiles(): string[] {
|
|
67
|
+
const allWorkspaces = workspaces();
|
|
68
|
+
const workspacePaths = [
|
|
69
|
+
...new Set(Object.values(allWorkspaces).map((w) => w.rootPath)),
|
|
70
|
+
];
|
|
71
|
+
return workspacePaths.flatMap((wsPath) =>
|
|
72
|
+
globSync(path.join(rootPath, wsPath, "**/env.yaml"))
|
|
73
|
+
);
|
|
74
|
+
}
|