@alicesystems/cli 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +29 -2
- package/dist/apps/cli/package.json +17 -0
- package/dist/apps/cli/src/commands/init/index.mjs +45 -0
- package/dist/apps/cli/src/commands/init/prompts.mjs +38 -0
- package/dist/apps/cli/src/helpers/validation.mjs +53 -0
- package/dist/apps/cli/src/index.mjs +37 -0
- package/dist/index.mjs +2 -0
- package/dist/packages/template-generator/src/foundation.mjs +130 -0
- package/dist/packages/template-generator/templates/README.md +7 -0
- package/dist/packages/template-generator/templates/base/.editorconfig +12 -0
- package/dist/packages/template-generator/templates/base/.env.example +2 -0
- package/dist/packages/template-generator/templates/base/.gitattributes +3 -0
- package/dist/packages/template-generator/templates/base/.github/workflows/ci.yml +31 -0
- package/dist/packages/template-generator/templates/base/.gitleaks.toml +7 -0
- package/dist/packages/template-generator/templates/base/.husky/pre-commit +2 -0
- package/dist/packages/template-generator/templates/base/.husky/pre-push +2 -0
- package/dist/packages/template-generator/templates/base/.node-version +1 -0
- package/dist/packages/template-generator/templates/base/AGENTS.md +11 -0
- package/dist/packages/template-generator/templates/base/README.md +26 -0
- package/dist/packages/template-generator/templates/base/alice.json +38 -0
- package/dist/packages/template-generator/templates/base/biome.json +27 -0
- package/dist/packages/template-generator/templates/base/documentation/architecture.md +13 -0
- package/dist/packages/template-generator/templates/base/documentation/environment.md +24 -0
- package/dist/packages/template-generator/templates/base/documentation/infisical.md +39 -0
- package/dist/packages/template-generator/templates/base/documentation/validation-results.md +25 -0
- package/dist/packages/template-generator/templates/base/documentation/validation.md +21 -0
- package/dist/packages/template-generator/templates/base/gitignore.template +12 -0
- package/dist/packages/template-generator/templates/base/lint-staged.config.mjs +3 -0
- package/dist/packages/template-generator/templates/base/npmrc.template +2 -0
- package/dist/packages/template-generator/templates/base/package.json +42 -0
- package/dist/packages/template-generator/templates/base/packages/env/README.md +9 -0
- package/dist/packages/template-generator/templates/base/packages/env/package.json +32 -0
- package/dist/packages/template-generator/templates/base/packages/env/src/client.ts +5 -0
- package/dist/packages/template-generator/templates/base/packages/env/src/policy.ts +9 -0
- package/dist/packages/template-generator/templates/base/packages/env/src/server.ts +15 -0
- package/dist/packages/template-generator/templates/base/packages/env/tests/env.test.ts +66 -0
- package/dist/packages/template-generator/templates/base/packages/env/tsconfig.json +10 -0
- package/dist/packages/template-generator/templates/base/packages/env/tsconfig.tooling.json +9 -0
- package/dist/packages/template-generator/templates/base/packages/env/tsdown.config.ts +11 -0
- package/dist/packages/template-generator/templates/base/packages/env/vitest.config.ts +16 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/README.md +7 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/base.json +15 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/bundler.json +9 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/nextjs.json +12 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/node.json +6 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/package.json +12 -0
- package/dist/packages/template-generator/templates/base/packages/typescript/react.json +8 -0
- package/dist/packages/template-generator/templates/base/pnpm-lock.yaml +1664 -0
- package/dist/packages/template-generator/templates/base/pnpm-workspace.yaml +10 -0
- package/dist/packages/template-generator/templates/base/scripts/check-presets.mjs +14 -0
- package/dist/packages/template-generator/templates/base/scripts/e2e.mjs +8 -0
- package/dist/packages/template-generator/templates/base/scripts/infisical-connect.mjs +119 -0
- package/dist/packages/template-generator/templates/base/scripts/infisical-local.mjs +509 -0
- package/dist/packages/template-generator/templates/base/scripts/prepare.mjs +15 -0
- package/dist/packages/template-generator/templates/base/scripts/secrets.mjs +68 -0
- package/dist/packages/template-generator/templates/base/scripts/security-tools.mjs +58 -0
- package/dist/packages/template-generator/templates/base/scripts/setup-infisical-local.mjs +115 -0
- package/dist/packages/template-generator/templates/base/scripts/setup-local.mjs +8 -0
- package/dist/packages/template-generator/templates/base/tests/fixtures/browser/boundary.ts +13 -0
- package/dist/packages/template-generator/templates/base/tests/fixtures/browser/tsconfig.json +8 -0
- package/dist/packages/template-generator/templates/base/tests/fixtures/node/boundary.ts +4 -0
- package/dist/packages/template-generator/templates/base/tests/fixtures/node/tsconfig.json +4 -0
- package/dist/packages/template-generator/templates/base/tests/foundation.test.mjs +39 -0
- package/dist/packages/template-generator/templates/base/tooling/ultracite/LICENSE +7 -0
- package/dist/packages/template-generator/templates/base/tooling/ultracite/README.md +10 -0
- package/dist/packages/template-generator/templates/base/tooling/ultracite/core/biome.jsonc +706 -0
- package/dist/packages/template-generator/templates/base/tsconfig.json +1 -0
- package/dist/packages/template-generator/templates/base/turbo.json +28 -0
- package/package.json +15 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Infisical setup status
|
|
2
|
+
|
|
3
|
+
Infisical is the selected secrets provider direction. The foundation works before provider setup. Its local Docker helper can configure/start a local instance; it does not create accounts, link secrets projects, or sync values automatically.
|
|
4
|
+
|
|
5
|
+
The reviewed init/setup workflow offers:
|
|
6
|
+
|
|
7
|
+
1. Create a local Docker instance.
|
|
8
|
+
2. Connect an existing self-hosted instance.
|
|
9
|
+
3. Use Infisical Cloud with an explicit region/account choice.
|
|
10
|
+
|
|
11
|
+
Follow the official setup documentation for the selected instance. Account login/consent and resource/region decisions remain user steps; supported technical operations can be automated after verification. Sync root values explicitly, preserve unrelated keys, and resolve local/remote conflicts without printing values.
|
|
12
|
+
|
|
13
|
+
## Local Docker development setup
|
|
14
|
+
|
|
15
|
+
Run `pnpm setup:infisical` from this workspace. It previews an isolated Docker project, then asks before generating keys or starting containers. The default URL is http://127.0.0.1:8088; a custom port can be chosen. Infisical's own PostgreSQL and Redis are private service dependencies, not optional app capabilities. Only the web port is published, bound to loopback. Container images are pinned by tag and digest.
|
|
16
|
+
|
|
17
|
+
Bootstrap secrets are generated securely once and appended to the single ignored root `.env`: `ALICE_INFISICAL_ENCRYPTION_KEY`, `ALICE_INFISICAL_AUTH_SECRET`, `ALICE_INFISICAL_POSTGRES_PASSWORD`, and `ALICE_INFISICAL_REDIS_PASSWORD`. Existing project values are preserved; existing valid bootstrap values are reused. Invalid, duplicate, or missing recovery keys on an existing configured instance cause setup to stop rather than rotate them.
|
|
18
|
+
|
|
19
|
+
The Compose definition in `infrastructure/infisical/compose.yaml` contains key references, not secret values. Each container receives only its explicit environment settings; the root file is not passed wholesale into services. `.env.example` documents bootstrap names with blank values. The helper's `projectValues` filter excludes all reserved `ALICE_INFISICAL_*` names from future project sync/injection selection. Never upload the complete root file to Infisical or pass it wholesale to apps.
|
|
20
|
+
|
|
21
|
+
`.alice/infisical-local.json` is ignored local runtime metadata. It distinguishes configured/not-verified from instance-ready/account-setup-pending. Neither status proves authentication, project linkage, environment provisioning, or secret sync. No new architecture manifest fields are invented by this helper.
|
|
22
|
+
|
|
23
|
+
Open the displayed URL to create your administrator account and select/create the organisation and secrets project. Alice never invents account credentials or accepts terms. SMTP is not configured here, so email invitations/password recovery need a later explicit email setup.
|
|
24
|
+
|
|
25
|
+
The interactive helper then offers CLI login/linking. After you confirm that browser setup is complete, it invokes Infisical CLI 0.43.140 with the explicit local API domain and a project-specific login profile. You complete authentication and select the project through Infisical's own supported interface. Existing `.infisical.json` files are preserved rather than overwritten. This helper validates that a project identity was written but does not prove remote environment readiness or secret sync. CLI version/help compatibility was checked locally; actual account authentication must be completed by the user. Other CLI versions need compatibility verification before this optional connection step runs.
|
|
26
|
+
|
|
27
|
+
Conflict-aware root sync, selected environment creation/mapping, connection/access verification and secure backup/rotation workflows are subsequent adapter work. Neither startup nor CLI linking uploads the root file.
|
|
28
|
+
|
|
29
|
+
## Persistence and recovery
|
|
30
|
+
|
|
31
|
+
Named Docker volumes preserve Infisical's database and Redis data across container restarts. Keep an access-controlled backup of the root `.env` and a corresponding database backup; losing the encryption key can make the stored secrets unrecoverable. Docker administrators can inspect container environment secrets. This local HTTP loopback deployment is not a public production hosting configuration.
|
|
32
|
+
|
|
33
|
+
Failed startup retains keys, configuration, and volumes for retry; it never deletes volumes or claims a provider connection succeeded. Repeat the command with the same directory/port to reuse the instance. Changing ports/projects or edited Compose definitions requires deliberate migration; the helper refuses automatic replacement. Moving the project directory changes the deterministic Docker project identity and needs a migration plan.
|
|
34
|
+
|
|
35
|
+
Stop safely with `docker compose --env-file .env -f infrastructure/infisical/compose.yaml down` from the project root. Do not add `--volumes`. A stale `.alice/infisical-setup.lock` after process interruption must be inspected before removal; crash recovery and upgrades/backups are not automated yet.
|
|
36
|
+
|
|
37
|
+
Runtime injection remains scoped to the owning consumer. Tests must never select production values. The local setup helper does not sync anything or inject the bootstrap keys into product code.
|
|
38
|
+
|
|
39
|
+
Sources: https://infisical.com/docs/self-hosting/deployment-options/docker-compose, https://infisical.com/docs/self-hosting/configuration/envars, https://docs.docker.com/compose/how-tos/environment-variables/envvars-precedence/, and https://infisical.com/docs/cli/overview.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Reference validation — 8 October 2026
|
|
2
|
+
|
|
3
|
+
Validated on Windows with Node 24.21.0 and pnpm 12.9.1, including a fresh standalone copy containing only the template payload and frozen lockfile.
|
|
4
|
+
|
|
5
|
+
| Check | Result |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Frozen installation | Passed in a fresh standalone Git workspace |
|
|
8
|
+
| Read-only Biome checks | Passed |
|
|
9
|
+
| Env ESM/declaration production build | Passed |
|
|
10
|
+
| Strict source/tooling typechecks | Passed |
|
|
11
|
+
| Browser/Node consumer fixtures | Passed; Node globals rejected in browser source |
|
|
12
|
+
| Env unit tests | 10 passed |
|
|
13
|
+
| Foundation/runtime tests | 4 passed |
|
|
14
|
+
| Coverage | Gates passed; executable env policy/server source fully exercised |
|
|
15
|
+
| Gitleaks workspace scan | Passed, no leaks found |
|
|
16
|
+
| Dependency audit | No known vulnerabilities reported at validation time |
|
|
17
|
+
| Husky installation and staged quality checks | Passed in the standalone copy |
|
|
18
|
+
| Scanner staged-index isolation | Passed: unrelated unstaged synthetic token ignored, staged synthetic token rejected, output redacted |
|
|
19
|
+
| Root env preservation and Git ignore | Passed |
|
|
20
|
+
| Browser E2E | Not applicable: no apps exist |
|
|
21
|
+
| Documentation site build | Passed in the Alice CLI documentation workspace |
|
|
22
|
+
|
|
23
|
+
These results apply to the reference and selected local tooling, not every future app/provider combination. Hosted GitHub Actions, Linux execution, Infisical connection, final CLI schema, and generation/rollback are not validated by this run. Security advisories can change after the recorded date.
|
|
24
|
+
|
|
25
|
+
See validation.md for compatibility findings, scanner support, and the static Ultracite preset mitigation. No security finding was suppressed to obtain a passing audit.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Validation and limitations
|
|
2
|
+
|
|
3
|
+
pnpm validate runs read-only quality checks, production build, runtime-specific typechecks, Vitest coverage, foundation fixtures, and explicit browser-E2E applicability. The no-app result is not a browser test pass.
|
|
4
|
+
|
|
5
|
+
Env tests cover runtime modes, invalid values, local schema composition, public-only exports, browser server-access denial, and error redaction. Compiler fixtures catch Node globals in browser source and strict indexed/optional-property behavior. Built-output tests check valid aliases, declarations, separate exports, and production Node imports.
|
|
6
|
+
|
|
7
|
+
Coverage gates are 80% lines/statements/functions and 75% branches for env source. Configuration-only TypeScript presets are checked through compiler fixtures, not fictional source coverage. Framework presets still require their future app fixtures.
|
|
8
|
+
|
|
9
|
+
pnpm security:tools downloads a pinned Gitleaks 8.30.1 archive into ignored .tools and verifies the recorded SHA256. It supports Windows/Linux x64 in this reference. pnpm security:secrets scans workspace files with value redaction. Pre-commit scans staged changes and runs lint-staged. Dependency auditing blocks high/critical advisories and fails if the registry check fails. No automatic audit fixes.
|
|
10
|
+
|
|
11
|
+
The provisional scanner/version is a fixture choice, not the permanent Alice release policy. The checksums were verified against the official GitHub release asset metadata. .tools is a local cache, not a machine-wide install.
|
|
12
|
+
|
|
13
|
+
CI uses pinned action commits, Node/pnpm pins, frozen install, no provider/deployment credentials, and read-only permissions. Branch protection must be configured separately. Hosted CI has not run until the workflow is pushed and executed.
|
|
14
|
+
|
|
15
|
+
The reference is not a complete SaaS or proof of production readiness. Infisical onboarding, all product apps/capabilities, macOS/ARM scanner support, final Alice manifest schema, and the CLI generation/rollback engine remain unfinished.
|
|
16
|
+
|
|
17
|
+
## Compatibility findings addressed in the reference
|
|
18
|
+
|
|
19
|
+
TypeScript is pinned to 6.0.3: the candidate TypeScript 7 builder API was reported experimental by tsdown. Shared presets remain strict with skipLibCheck=false. The mixed env package alone includes DOM declarations to supply the standard URL type referenced by Zod; it receives no Node ambient types. Generic presets remain runtime-neutral, and browser fixtures verify Node globals do not leak.
|
|
20
|
+
|
|
21
|
+
The static Ultracite 7.12.4 Biome preset is preserved under tooling/ultracite with its licence/provenance. Its unused setup CLI is not installed because that dependency chain contains an unpatched high-severity braces advisory. The dependency gate remains enabled without advisory suppression.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alice-reference",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "turbo run build",
|
|
8
|
+
"check": "biome check .",
|
|
9
|
+
"format": "biome check --write .",
|
|
10
|
+
"prepare": "node scripts/prepare.mjs",
|
|
11
|
+
"security:audit": "pnpm audit --audit-level high",
|
|
12
|
+
"security:secrets": "node scripts/secrets.mjs",
|
|
13
|
+
"security:staged": "node scripts/secrets.mjs --staged",
|
|
14
|
+
"security:tools": "node scripts/security-tools.mjs",
|
|
15
|
+
"setup:infisical": "node scripts/setup-infisical-local.mjs --interactive",
|
|
16
|
+
"setup:local": "node scripts/setup-local.mjs",
|
|
17
|
+
"test": "turbo run test && node --test tests/foundation.test.mjs",
|
|
18
|
+
"test:coverage": "turbo run test:coverage && node --test tests/foundation.test.mjs",
|
|
19
|
+
"test:e2e": "node scripts/e2e.mjs",
|
|
20
|
+
"typecheck": "turbo run typecheck && node scripts/check-presets.mjs",
|
|
21
|
+
"validate": "pnpm check && pnpm build && pnpm typecheck && pnpm test:coverage && pnpm test:e2e",
|
|
22
|
+
"validate:security": "pnpm security:secrets && pnpm security:audit"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@alice-reference/env": "workspace:*",
|
|
26
|
+
"@alice-reference/typescript": "workspace:*",
|
|
27
|
+
"@biomejs/biome": "2.5.15",
|
|
28
|
+
"@playwright/test": "1.64.0",
|
|
29
|
+
"@types/node": "24.19.1",
|
|
30
|
+
"@vitest/coverage-v8": "5.0.3",
|
|
31
|
+
"husky": "9.1.7",
|
|
32
|
+
"lint-staged": "17.6.0",
|
|
33
|
+
"tsdown": "0.23.0",
|
|
34
|
+
"turbo": "2.11.7",
|
|
35
|
+
"typescript": "6.0.3",
|
|
36
|
+
"vitest": "5.0.3"
|
|
37
|
+
},
|
|
38
|
+
"packageManager": "pnpm@12.9.1",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=24.21.0 <25"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Shared env foundations
|
|
2
|
+
|
|
3
|
+
Use @alice-reference/env/server for createBaseEnv, createEnv, and envValidationPolicy. Use @alice-reference/env/client for client-safe createEnv and policy only. There is deliberately no root export merging the boundaries.
|
|
4
|
+
|
|
5
|
+
Create the base with explicit NODE_ENV and extend it in each owning app/package. Declare only the keys needed by that owner. The package never reads process.env globally or holds every capability's schema. Errors omit supplied values.
|
|
6
|
+
|
|
7
|
+
Pass envValidationPolicy when creating a local object; do not bypass validation. The client prefix and public runtime values belong to the selected framework adapter.
|
|
8
|
+
|
|
9
|
+
See ../../documentation/environment.md for local composition. Built ESM and declarations are used by consumers; pnpm build creates dist.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alice-reference/env",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./server": {
|
|
8
|
+
"types": "./dist/server.d.ts",
|
|
9
|
+
"import": "./dist/server.js"
|
|
10
|
+
},
|
|
11
|
+
"./client": {
|
|
12
|
+
"types": "./dist/client.d.ts",
|
|
13
|
+
"import": "./dist/client.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsdown",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:coverage": "vitest run --coverage",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.tooling.json"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@t3-oss/env-core": "0.13.11",
|
|
27
|
+
"zod": "4.6.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@alice-reference/typescript": "workspace:*"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Local consumers choose their framework's public prefix and explicit values.
|
|
2
|
+
// This entry point contains no server schema and never reads process.env.
|
|
3
|
+
// biome-ignore lint/performance/noBarrelFile: Deliberate client-safe boundary with no server exports.
|
|
4
|
+
export { createEnv } from "@t3-oss/env-core";
|
|
5
|
+
export { envValidationPolicy } from "@/policy";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const envValidationPolicy = {
|
|
2
|
+
emptyStringAsUndefined: true,
|
|
3
|
+
onInvalidAccess: () => {
|
|
4
|
+
throw new Error("Server environment access is forbidden in this runtime.");
|
|
5
|
+
},
|
|
6
|
+
onValidationError: () => {
|
|
7
|
+
throw new Error("Environment validation failed. Check the owning module's required keys.");
|
|
8
|
+
},
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { envValidationPolicy } from "@/policy";
|
|
4
|
+
|
|
5
|
+
// biome-ignore lint/performance/noBarrelFile: Deliberate small public package boundary.
|
|
6
|
+
export { createEnv } from "@t3-oss/env-core";
|
|
7
|
+
export { envValidationPolicy } from "@/policy";
|
|
8
|
+
|
|
9
|
+
export function createBaseEnv(runtimeEnv: { NODE_ENV?: string | undefined }) {
|
|
10
|
+
return createEnv({
|
|
11
|
+
runtimeEnvStrict: { NODE_ENV: runtimeEnv.NODE_ENV },
|
|
12
|
+
server: { NODE_ENV: z.enum(["development", "test", "production"]) },
|
|
13
|
+
...envValidationPolicy,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { envValidationPolicy as clientPolicy, createEnv as createClientEnv } from "@/client";
|
|
4
|
+
import { createBaseEnv, createEnv, envValidationPolicy } from "@/server";
|
|
5
|
+
|
|
6
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
7
|
+
|
|
8
|
+
describe("shared base and local ownership", () => {
|
|
9
|
+
it.each(["development", "test", "production"])("validates %s", (NODE_ENV) => {
|
|
10
|
+
expect(createBaseEnv({ NODE_ENV }).NODE_ENV).toBe(NODE_ENV);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it.each([undefined, "", "staging"])(
|
|
14
|
+
"rejects invalid runtime modes without exposing values",
|
|
15
|
+
(NODE_ENV) => {
|
|
16
|
+
const runtime = NODE_ENV === undefined ? {} : { NODE_ENV };
|
|
17
|
+
expect(() => createBaseEnv(runtime)).toThrow("Environment validation failed");
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
it("composes a local package's schema without moving it into the base", () => {
|
|
22
|
+
const base = createBaseEnv({ NODE_ENV: "development" });
|
|
23
|
+
const local = createEnv({
|
|
24
|
+
extends: [base],
|
|
25
|
+
runtimeEnvStrict: { DATABASE_URL: "https://database.example.test" },
|
|
26
|
+
server: { DATABASE_URL: z.url() },
|
|
27
|
+
...envValidationPolicy,
|
|
28
|
+
});
|
|
29
|
+
expect(local.NODE_ENV).toBe("development");
|
|
30
|
+
expect(local.DATABASE_URL).toBe("https://database.example.test");
|
|
31
|
+
expect(Object.keys(base)).not.toContain("DATABASE_URL");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("does not leak invalid supplied values in validation errors", () => {
|
|
35
|
+
const invalidValue = "synthetic-invalid-private-value";
|
|
36
|
+
try {
|
|
37
|
+
createEnv({
|
|
38
|
+
runtimeEnvStrict: { PRIVATE_VALUE: invalidValue },
|
|
39
|
+
server: { PRIVATE_VALUE: z.url() },
|
|
40
|
+
...envValidationPolicy,
|
|
41
|
+
});
|
|
42
|
+
throw new Error("Expected validation failure");
|
|
43
|
+
} catch (error) {
|
|
44
|
+
expect(String(error)).toContain("Environment validation failed");
|
|
45
|
+
expect(String(error)).not.toContain(invalidValue);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("rejects server access in a browser runtime", () => {
|
|
50
|
+
vi.stubGlobal("window", {});
|
|
51
|
+
const base = createBaseEnv({ NODE_ENV: "production" });
|
|
52
|
+
expect(() => base.NODE_ENV).toThrow("Server environment access is forbidden");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("creates a public-only local client boundary", () => {
|
|
56
|
+
vi.stubGlobal("window", {});
|
|
57
|
+
const client = createClientEnv({
|
|
58
|
+
client: { PUBLIC_API_URL: z.url() },
|
|
59
|
+
clientPrefix: "PUBLIC_",
|
|
60
|
+
runtimeEnvStrict: { PUBLIC_API_URL: "https://api.example.test" },
|
|
61
|
+
...clientPolicy,
|
|
62
|
+
});
|
|
63
|
+
expect(client.PUBLIC_API_URL).toBe("https://api.example.test");
|
|
64
|
+
expect(Object.keys(client)).not.toContain("NODE_ENV");
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) } },
|
|
6
|
+
test: {
|
|
7
|
+
coverage: {
|
|
8
|
+
include: ["src/**/*.ts"],
|
|
9
|
+
provider: "v8",
|
|
10
|
+
reporter: ["text", "json", "html"],
|
|
11
|
+
thresholds: { branches: 75, functions: 80, lines: 80, statements: 80 },
|
|
12
|
+
},
|
|
13
|
+
environment: "node",
|
|
14
|
+
include: ["tests/**/*.test.ts"],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Shared TypeScript presets
|
|
2
|
+
|
|
3
|
+
The base has strict checking and no automatic ambient runtime types. Bundler adds ES2022; Node adds Node types; React and Next presets require their consumer's framework dependencies. No framework is installed in the empty foundation.
|
|
4
|
+
|
|
5
|
+
Consumers extend @alice-reference/typescript/<preset>.json and declare workspace:* dev dependencies. Each defines @/* locally. Exports are JSON configuration only. Expo retains its own SDK base and composes Alice strictness when its adapter is added.
|
|
6
|
+
|
|
7
|
+
The reference validates runtime-neutral/browser type boundaries and the env build. React/Next/Expo fixtures are future adapter checks, not completed by this base.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"noUncheckedIndexedAccess": true,
|
|
5
|
+
"exactOptionalPropertyTypes": true,
|
|
6
|
+
"noImplicitOverride": true,
|
|
7
|
+
"noFallthroughCasesInSwitch": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"verbatimModuleSyntax": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"skipLibCheck": false,
|
|
13
|
+
"types": []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alice-reference/typescript",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"exports": {
|
|
6
|
+
"./base.json": "./base.json",
|
|
7
|
+
"./bundler.json": "./bundler.json",
|
|
8
|
+
"./node.json": "./node.json",
|
|
9
|
+
"./react.json": "./react.json",
|
|
10
|
+
"./nextjs.json": "./nextjs.json"
|
|
11
|
+
}
|
|
12
|
+
}
|