@envmanager-cli/cli 0.1.10 → 0.2.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/dist/bin/envmanager.js +28 -9
- package/dist/bin/envmanager.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/envmanager.js
CHANGED
|
@@ -615,7 +615,8 @@ var ConfigSchema = z.object({
|
|
|
615
615
|
api_url: z.string().url().optional(),
|
|
616
616
|
format: z.enum(EXPORT_FORMATS).optional(),
|
|
617
617
|
k8s_namespace: z.string().optional(),
|
|
618
|
-
k8s_name: z.string().optional()
|
|
618
|
+
k8s_name: z.string().optional(),
|
|
619
|
+
tags: z.array(z.string()).optional()
|
|
619
620
|
});
|
|
620
621
|
var CONFIG_FILENAMES = ["envmanager.json", ".envmanagerrc"];
|
|
621
622
|
function findConfigFile(startDir = process.cwd()) {
|
|
@@ -885,7 +886,7 @@ function resolveAll(variables) {
|
|
|
885
886
|
}
|
|
886
887
|
|
|
887
888
|
// src/commands/pull.ts
|
|
888
|
-
var pullCommand = new Command4("pull").description("Pull environment variables from EnvManager to local .env file").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("-o, --output <file>", "Output file path (default: .env)").option("--no-secrets", "Exclude secret values (will be empty)").option("-f, --force", "Overwrite existing file without prompting").option("-r, --resolve-references", "Resolve ${VAR} references to their values").option("-F, --include-fallbacks", "Include fallback values for empty variables").option("-s, --show-sources", "Show value source as inline comments").option("--format <type>", `Export format (${EXPORT_FORMATS.join(", ")})`).option("--k8s-namespace <ns>", 'Kubernetes namespace (default: "default")').option("--k8s-name <name>", "Kubernetes resource name").action(async (options) => {
|
|
889
|
+
var pullCommand = new Command4("pull").description("Pull environment variables from EnvManager to local .env file").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("-o, --output <file>", "Output file path (default: .env)").option("--no-secrets", "Exclude secret values (will be empty)").option("-f, --force", "Overwrite existing file without prompting").option("-r, --resolve-references", "Resolve ${VAR} references to their values").option("-F, --include-fallbacks", "Include fallback values for empty variables").option("-s, --show-sources", "Show value source as inline comments").option("--format <type>", `Export format (${EXPORT_FORMATS.join(", ")})`).option("--k8s-namespace <ns>", 'Kubernetes namespace (default: "default")').option("--k8s-name <name>", "Kubernetes resource name").option("--tag <tags...>", "Filter by tags (untagged variables always included)").action(async (options) => {
|
|
889
890
|
const spinner = ora3("Connecting to EnvManager...").start();
|
|
890
891
|
try {
|
|
891
892
|
const config = loadConfig();
|
|
@@ -957,7 +958,11 @@ File ${outputFile} already exists.`));
|
|
|
957
958
|
console.log(chalk4.gray("Use --force to overwrite."));
|
|
958
959
|
process.exit(1);
|
|
959
960
|
}
|
|
960
|
-
const
|
|
961
|
+
const filterTags = options.tag || config?.tags || [];
|
|
962
|
+
const vars = filterTags.length > 0 ? variables.filter((v) => {
|
|
963
|
+
const t = v.tags || [];
|
|
964
|
+
return t.length === 0 || t.some((tag) => filterTags.includes(tag));
|
|
965
|
+
}).sort((a, b) => a.key.localeCompare(b.key)) : variables.sort((a, b) => a.key.localeCompare(b.key));
|
|
961
966
|
let resolvedMap = null;
|
|
962
967
|
if (shouldResolve) {
|
|
963
968
|
spinner.text = "Resolving variable references...";
|
|
@@ -1034,7 +1039,8 @@ File ${outputFile} already exists.`));
|
|
|
1034
1039
|
writeFileSync2(outputFile, content + "\n");
|
|
1035
1040
|
const secretCount = vars.filter((v) => v.is_secret).length;
|
|
1036
1041
|
const plainCount = vars.length - secretCount;
|
|
1037
|
-
|
|
1042
|
+
const tagInfo = filterTags.length > 0 ? ` (tags: ${filterTags.join(", ")})` : "";
|
|
1043
|
+
spinner.succeed(`Pulled ${vars.length} variables to ${outputFile} (${format})${tagInfo}`);
|
|
1038
1044
|
console.log(chalk4.gray(` ${plainCount} plain, ${secretCount} secrets`));
|
|
1039
1045
|
client.rpc("log_variable_access", {
|
|
1040
1046
|
p_environment_id: environmentId,
|
|
@@ -1340,7 +1346,7 @@ import chalk7 from "chalk";
|
|
|
1340
1346
|
import ora5 from "ora";
|
|
1341
1347
|
import { readFileSync as readFileSync4, existsSync as existsSync5 } from "fs";
|
|
1342
1348
|
import { resolve as resolve3 } from "path";
|
|
1343
|
-
var diffCommand = new Command6("diff").description("Show differences between local .env and EnvManager").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("-i, --input <file>", "Input file path (default: .env)").option("--keys-only", "Only show key names, not values").action(async (options) => {
|
|
1349
|
+
var diffCommand = new Command6("diff").description("Show differences between local .env and EnvManager").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("-i, --input <file>", "Input file path (default: .env)").option("--keys-only", "Only show key names, not values").option("--tag <tags...>", "Filter by tags (untagged variables always included)").action(async (options) => {
|
|
1344
1350
|
const spinner = ora5("Comparing...").start();
|
|
1345
1351
|
try {
|
|
1346
1352
|
const config = loadConfig();
|
|
@@ -1392,8 +1398,13 @@ var diffCommand = new Command6("diff").description("Show differences between loc
|
|
|
1392
1398
|
console.error(chalk7.red(varError.message));
|
|
1393
1399
|
process.exit(1);
|
|
1394
1400
|
}
|
|
1401
|
+
const filterTags = options.tag || config?.tags || [];
|
|
1402
|
+
const filteredRemoteData = filterTags.length > 0 ? (remoteVarsData || []).filter((v) => {
|
|
1403
|
+
const t = v.tags || [];
|
|
1404
|
+
return t.length === 0 || t.some((tag) => filterTags.includes(tag));
|
|
1405
|
+
}) : remoteVarsData || [];
|
|
1395
1406
|
const remoteVars = /* @__PURE__ */ new Map();
|
|
1396
|
-
for (const v of
|
|
1407
|
+
for (const v of filteredRemoteData) {
|
|
1397
1408
|
remoteVars.set(v.key, v);
|
|
1398
1409
|
}
|
|
1399
1410
|
spinner.stop();
|
|
@@ -1877,7 +1888,7 @@ function mergeWithRemote(local, remoteVariables, strategy) {
|
|
|
1877
1888
|
}
|
|
1878
1889
|
|
|
1879
1890
|
// src/commands/dev.ts
|
|
1880
|
-
var devCommand = new Command9("dev").description("Start real-time sync daemon - watches for remote variable changes").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("--output <file>", "Output file path (default: .env)").option("--no-watch", "Disable local file watching").option("--strategy <type>", "Merge strategy: remote_wins, local_wins, merge_new (default: remote_wins)", "remote_wins").action(async (options) => {
|
|
1891
|
+
var devCommand = new Command9("dev").description("Start real-time sync daemon - watches for remote variable changes").option("--org <name>", "Organization name (required if you belong to multiple)").option("-e, --environment <name>", 'Environment name (default: from config or "development")').option("-p, --project <id>", "Project ID (default: from config)").option("--output <file>", "Output file path (default: .env)").option("--no-watch", "Disable local file watching").option("--strategy <type>", "Merge strategy: remote_wins, local_wins, merge_new (default: remote_wins)", "remote_wins").option("--tag <tags...>", "Filter by tags (untagged variables always included)").action(async (options) => {
|
|
1881
1892
|
const spinner = ora7("Starting dev mode...").start();
|
|
1882
1893
|
try {
|
|
1883
1894
|
const config = loadConfig();
|
|
@@ -1914,8 +1925,16 @@ var devCommand = new Command9("dev").description("Start real-time sync daemon -
|
|
|
1914
1925
|
process.exit(1);
|
|
1915
1926
|
}
|
|
1916
1927
|
const environmentId = environment.id;
|
|
1928
|
+
const filterTags = options.tag || config?.tags || [];
|
|
1929
|
+
const applyTagFilter = (vars) => {
|
|
1930
|
+
if (filterTags.length === 0) return vars;
|
|
1931
|
+
return vars.filter((v) => {
|
|
1932
|
+
const t = v.tags || [];
|
|
1933
|
+
return t.length === 0 || t.some((tag) => filterTags.includes(tag));
|
|
1934
|
+
});
|
|
1935
|
+
};
|
|
1917
1936
|
spinner.text = "Performing initial sync...";
|
|
1918
|
-
const remoteVariables = await fetchAllVariables(environmentId, true);
|
|
1937
|
+
const remoteVariables = applyTagFilter(await fetchAllVariables(environmentId, true));
|
|
1919
1938
|
let localVariables = /* @__PURE__ */ new Map();
|
|
1920
1939
|
if (existsSync7(outputFile)) {
|
|
1921
1940
|
const content = readFileSync6(outputFile, "utf-8");
|
|
@@ -1932,7 +1951,7 @@ var devCommand = new Command9("dev").description("Start real-time sync daemon -
|
|
|
1932
1951
|
let isPaused = false;
|
|
1933
1952
|
let lastRemoteKeys = null;
|
|
1934
1953
|
async function syncRemoteToLocal(silent = false) {
|
|
1935
|
-
const updatedVariables = await fetchAllVariables(environmentId, true);
|
|
1954
|
+
const updatedVariables = applyTagFilter(await fetchAllVariables(environmentId, true));
|
|
1936
1955
|
const currentLocal = /* @__PURE__ */ new Map();
|
|
1937
1956
|
if (existsSync7(outputFile)) {
|
|
1938
1957
|
const content = readFileSync6(outputFile, "utf-8");
|