@apso/cli 0.49.1 → 0.49.2

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.
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const services_1 = require("../api/services");
8
+ const git_1 = require("../git");
8
9
  // Never ship these into the code zip — the backend reconstitutes the runnable
9
10
  // base template and only needs the source + schema + user edits.
10
11
  const EXCLUDE_DIRS = new Set([
@@ -15,17 +16,6 @@ const EXCLUDE_DIRS = new Set([
15
16
  ".apso",
16
17
  "coverage",
17
18
  ]);
18
- /**
19
- * Never push local secrets to the repo. `.env` and `.env.*` (e.g. `.env.local`)
20
- * routinely hold DB passwords and session secrets; `.env.example` is the one
21
- * env file that is meant to be committed. The backend injects real production
22
- * env at runtime, so these are never needed in the pushed code.
23
- */
24
- function isSecretEnvFile(basename) {
25
- if (basename === ".env.example" || basename === ".env.sample")
26
- return false;
27
- return basename === ".env" || basename.startsWith(".env.");
28
- }
29
19
  /** Zip the project source into a buffer, skipping build/vcs/dependency/secret files. */
30
20
  function zipProject(cwd) {
31
21
  const zip = new adm_zip_1.default();
@@ -36,7 +26,7 @@ function zipProject(cwd) {
36
26
  if (!kept && parts.some((p) => EXCLUDE_DIRS.has(p)))
37
27
  return false;
38
28
  const base = parts[parts.length - 1];
39
- if (isSecretEnvFile(base))
29
+ if ((0, git_1.isSecretEnvFile)(base))
40
30
  return false;
41
31
  return true;
42
32
  });
package/dist/lib/git.d.ts CHANGED
@@ -16,7 +16,20 @@ export declare function parseRepoFullName(url: string | null): string | null;
16
16
  export declare function localRepoFullName(cwd: string): string | null;
17
17
  export declare function setOrigin(cwd: string, repoUrl: string): void;
18
18
  export declare function hasUncommittedChanges(cwd: string): boolean;
19
- /** Stage everything and commit, unless there is nothing to commit. */
19
+ /**
20
+ * Never push local secrets to the repo. `.env` and `.env.*` (e.g. `.env.local`)
21
+ * routinely hold DB passwords and session secrets; `.env.example` and
22
+ * `.env.sample` are the env files meant to be committed. The backend injects
23
+ * real production env at runtime, so these are never needed in the pushed code.
24
+ */
25
+ export declare function isSecretEnvFile(basename: string): boolean;
26
+ /**
27
+ * Keep secret env files out of commits: add them to .gitignore (the TS template
28
+ * only ignores `.env`, so `.env.local` got committed) and untrack any that an
29
+ * earlier commit already picked up.
30
+ */
31
+ export declare function ignoreSecretEnvFiles(cwd: string): void;
32
+ /** Stage everything (minus secret env files) and commit, unless there is nothing to commit. */
20
33
  export declare function commitAll(cwd: string, message: string): boolean;
21
34
  /** Attribution trailer appended to every commit the CLI creates. */
22
35
  export declare const APSO_COMMIT_TRAILER = "Generated with Apso (https://apso.ai)";
package/dist/lib/git.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * deploy time.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.httpsUrlFor = exports.pushHead = exports.APSO_COMMIT_TRAILER = exports.commitAll = exports.hasUncommittedChanges = exports.setOrigin = exports.localRepoFullName = exports.parseRepoFullName = exports.getOriginUrl = exports.initRepo = exports.isGitRepo = exports.gitAvailable = void 0;
11
+ exports.httpsUrlFor = exports.pushHead = exports.APSO_COMMIT_TRAILER = exports.commitAll = exports.ignoreSecretEnvFiles = exports.isSecretEnvFile = exports.hasUncommittedChanges = exports.setOrigin = exports.localRepoFullName = exports.parseRepoFullName = exports.getOriginUrl = exports.initRepo = exports.isGitRepo = exports.gitAvailable = void 0;
12
12
  const tslib_1 = require("tslib");
13
13
  const child_process_1 = require("child_process");
14
14
  const fs = tslib_1.__importStar(require("fs"));
@@ -77,8 +77,44 @@ function hasUncommittedChanges(cwd) {
77
77
  return run("git status --porcelain", cwd).length > 0;
78
78
  }
79
79
  exports.hasUncommittedChanges = hasUncommittedChanges;
80
- /** Stage everything and commit, unless there is nothing to commit. */
80
+ /**
81
+ * Never push local secrets to the repo. `.env` and `.env.*` (e.g. `.env.local`)
82
+ * routinely hold DB passwords and session secrets; `.env.example` and
83
+ * `.env.sample` are the env files meant to be committed. The backend injects
84
+ * real production env at runtime, so these are never needed in the pushed code.
85
+ */
86
+ function isSecretEnvFile(basename) {
87
+ if (basename === ".env.example" || basename === ".env.sample")
88
+ return false;
89
+ return basename === ".env" || basename.startsWith(".env.");
90
+ }
91
+ exports.isSecretEnvFile = isSecretEnvFile;
92
+ const SECRET_ENV_IGNORES = [".env", ".env.*", "!.env.example", "!.env.sample"];
93
+ /**
94
+ * Keep secret env files out of commits: add them to .gitignore (the TS template
95
+ * only ignores `.env`, so `.env.local` got committed) and untrack any that an
96
+ * earlier commit already picked up.
97
+ */
98
+ function ignoreSecretEnvFiles(cwd) {
99
+ const file = path.join(cwd, ".gitignore");
100
+ const current = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : "";
101
+ const have = new Set(current.split(/\r?\n/).map((l) => l.trim()));
102
+ const missing = SECRET_ENV_IGNORES.filter((l) => !have.has(l));
103
+ if (missing.length > 0) {
104
+ const sep = current && !current.endsWith("\n") ? "\n" : "";
105
+ fs.writeFileSync(file, `${current}${sep}# Local secrets, never committed (added by apso)\n${missing.join("\n")}\n`);
106
+ }
107
+ const tracked = run("git ls-files", cwd)
108
+ .split("\n")
109
+ .filter((f) => f && isSecretEnvFile(path.basename(f)));
110
+ if (tracked.length > 0) {
111
+ run(`git rm --cached -q -- ${tracked.map((f) => JSON.stringify(f)).join(" ")}`, cwd);
112
+ }
113
+ }
114
+ exports.ignoreSecretEnvFiles = ignoreSecretEnvFiles;
115
+ /** Stage everything (minus secret env files) and commit, unless there is nothing to commit. */
81
116
  function commitAll(cwd, message) {
117
+ ignoreSecretEnvFiles(cwd);
82
118
  run("git add -A", cwd);
83
119
  if (!hasUncommittedChanges(cwd)) {
84
120
  // Something may still be staged with no worktree diff; check the index.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@apso/cli",
3
- "version": "0.49.1",
3
+ "version": "0.49.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@apso/cli",
9
- "version": "0.49.1",
9
+ "version": "0.49.2",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@apso/schema-tools": "^0.2.2",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.49.1",
2
+ "version": "0.49.2",
3
3
  "commands": {
4
4
  "config": {
5
5
  "id": "config",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apso/cli",
3
- "version": "0.49.1",
3
+ "version": "0.49.2",
4
4
  "mcpName": "io.github.apsoai/apso",
5
5
  "description": "Apso CLI",
6
6
  "author": "Apso by Mavric - @mavric",