Skip to content

Commit

Permalink
Replace AUSTENITE_SPEC with AUSTENITE_MODE
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Nov 7, 2024
1 parent b8e0470 commit f4eb54c
Show file tree
Hide file tree
Showing 65 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/.makefiles/
/artifacts/
/CHANGELOG.md
/test/fixture/specification/no-prettier/
/test/fixture/usage/no-prettier/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ artifacts/dist/esm: tsconfig.build.esm.json tsconfig.json artifacts/link-depende
@touch "$@"

ENVIRONMENT.md: artifacts/link-dependencies.touch artifacts/dist $(JS_SOURCE_FILES) $(JS_TEST_FILES)
AUSTENITE_SPEC=true AUSTENITE_APP=example node test/fixture/example/run.js > "$@"
AUSTENITE_MODE=usage/markdown AUSTENITE_APP=example node test/fixture/example/run.js > "$@"
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ Environment Variables:
❯ WEIGHT weighting for this node <integer> ✗ set to 0, must be >= 1
```

## Generated environment specifications
## Generated usage documentation

If the environment variable `AUSTENITE_SPEC` is set to `true`, calling
If the environment variable `AUSTENITE_MODE` is set to `usage/markdown`, calling
`initialize()` will terminate the process with a zero exit code, and output a
Markdown document containing a specification of the environment variables
Markdown document containing usage documentation for the environment variables
consumed by each declaration.

<!-- prettier-ignore-start -->
Expand All @@ -86,14 +86,14 @@ consumed by each declaration.
<!-- prettier-ignore-start -->
> [!TIP]
> If you have the [`prettier` NPM package] installed, Austenite will
> pretty-print specification output according to your Prettier config for a file
> at `./ENVIRONMENT.md`.
> pretty-print Markdown output according to your Prettier config for a file at
> `./ENVIRONMENT.md`.
>
> If you have Prettier installed, but don't have a config file for
> `./ENVIRONMENT.md`, Austenite will use its own default Prettier config.
>
> If you don't have Prettier installed, or if you set the `markdownPrettyPrint`
> option to `"none"`, Austenite won't pretty-print specification output.
> option to `"none"`, Austenite won't pretty-print Markdown output.
<!-- prettier-ignore-end -->
[`prettier` npm package]: https://npmjs.com/package/prettier
Expand Down
10 changes: 4 additions & 6 deletions src/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { EOL } from "node:os";
import { state, variablesByName } from "./environment.js";
import type { MarkdownPrettyPrintType } from "./specification.js";
import { render as renderSummary } from "./summary.js";
import type { MarkdownPrettyPrintType } from "./usage.js";
import { validate, type Results } from "./validation.js";

export async function initialize(
options: InitializeOptions = {},
): Promise<void> {
if (process.env.AUSTENITE_SPEC === "true") {
if (process.env.AUSTENITE_MODE === "usage/markdown") {
const { markdownPrettyPrint = "prettier" } = options;
const { render: renderSpecification } = await import("./specification.js");
const { render: renderUsage } = await import("./usage.js");

console.log(
await renderSpecification(markdownPrettyPrint, variablesByName()),
);
console.log(await renderUsage(markdownPrettyPrint, variablesByName()));

// eslint-disable-next-line n/no-process-exit
process.exit(0);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
import { MockConsole, createMockConsole } from "../helpers.js";

const fixturesPath = fileURLToPath(
new URL("../fixture/specification", import.meta.url),
new URL("../fixture/usage", import.meta.url),
);

describe("Specification documents (Prettier unavailable)", () => {
describe("Usage documentation (Prettier unavailable)", () => {
let exitCode: number | undefined;
let mockConsole: MockConsole;

Expand All @@ -30,7 +30,7 @@ describe("Specification documents (Prettier unavailable)", () => {
});

process.env = {
AUSTENITE_SPEC: "true",
AUSTENITE_MODE: "usage/markdown",
};

mockConsole = createMockConsole();
Expand Down
6 changes: 3 additions & 3 deletions test/suite/specification.spec.ts → test/suite/usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { MockConsole, createMockConsole } from "../helpers.js";

const fixturesPath = fileURLToPath(
new URL("../fixture/specification", import.meta.url),
new URL("../fixture/usage", import.meta.url),
);

const { Duration } = Temporal;

describe("Specification documents", () => {
describe("Usage documentation", () => {
let exitCode: number | undefined;
let mockConsole: MockConsole;

Expand All @@ -37,7 +37,7 @@ describe("Specification documents", () => {
});

process.env = {
AUSTENITE_SPEC: "true",
AUSTENITE_MODE: "usage/markdown",
};

mockConsole = createMockConsole();
Expand Down

0 comments on commit f4eb54c

Please sign in to comment.