Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ E.g. `.glf.json`, `.glfrc.yml`, `.generatelicensefile.jsonc`, `.config/glf.js`,
"exclude": ["your-package", "[email protected]", "/.*prettier.*/i"],

// Omit the version number in the output file
"omitVersion": false
"omitVersions": false
}
```

Expand Down
1 change: 0 additions & 1 deletion e2e/config-file/test/cli/append/append.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { output as outputFileName } from "./config.js";
const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when content is appended", async () => {
const configPath = "./test/cli/append/config.js";
Expand Down
1 change: 0 additions & 1 deletion e2e/config-file/test/cli/exclude/exclude.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { output as outputFileName } from "./config.js";
const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when content is excluded", async () => {
const configPath = "./test/cli/exclude/config.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { output as outputFileName } from "./config.js";
const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when inputs and outputs are provided via config file", async () => {
const configPath = "./test/cli/inputs-output/config.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cli should omit versions when omitVersions is true in config 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file

The following npm package may be included in this product:

- dep-four

This package contains the following license:

# Dep Four

This license file is spelt \`LICENCE\`.
This license should be found.

-----------

The following npm package may be included in this product:

- dep-one

This package contains the following license:

# Dep One

This license file is spelt \`LICENSE.md\`.
This license should be found.

-----------

The following npm package may be included in this product:

- dep-three

This package contains the following license:

# Dep Three

This license file is spelt \`LICENSE\`.
This license should be found.

-----------

The following npm packages may be included in this product:

- dep-two
- dep-two-duplicate

These packages each contain the following license:

# Dep Two

This license file is spelt \`LICENCE.md\`.
This license should be found.

-----------

The following npm package may be included in this product:

- dep-five

This package contains the following license:

MIT

-----------

This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;
7 changes: 7 additions & 0 deletions e2e/config-file/test/cli/omit-versions/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
inputs: ["./package.json"],
output: "omit-versions-config-output.txt",

// Test that versions are omitted from the output file.
omitVersions: true,
};
27 changes: 27 additions & 0 deletions e2e/config-file/test/cli/omit-versions/omit-versions.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { exec } from "child_process";
import fs from "fs/promises";
import { promisify } from "util";
import { output as outputFileName } from "./config.js";

const execAsync = promisify(exec);

describe("cli", () => {

it("should omit versions when omitVersions is true in config", async () => {
const configPath = "./test/cli/omit-versions/config.js";

await execAsync(`npx generate-license-file -c ${configPath}`);

const result = await fs.readFile(outputFileName, "utf8");

// Check that the output doesn't contain version numbers
// Should not contain patterns like "@1.0.0" or "[email protected]"
expect(result).not.toMatch(/@\d+\.\d+\.\d+/);

// Should contain package names without versions
expect(result).toMatch(/dep-one/);
expect(result).toMatchSnapshot();

await fs.unlink(outputFileName);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { output as outputFileName } from "./config.js";
const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when a package is replaced", async () => {
const configPath = "./test/cli/replacement/config.js";
Expand Down
2 changes: 1 addition & 1 deletion src/packages/generate-license-file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ E.g. `.glf.json`, `.glfrc.yml`, `.generatelicensefile.jsonc`, `.config/glf.js`,
"exclude": ["your-package", "[email protected]", "/.*prettier.*/i"],

// Omit the version number in the output file
"omitVersion": false
"omitVersions": false
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const configSchema = z
replace: z.record(z.string().nonempty(), z.string().nonempty()).optional(),
exclude: z.string().nonempty().array().optional(),
append: z.string().nonempty().array().optional(),
omitVersions: z.boolean().optional(),
})
.optional();

Expand Down
5 changes: 4 additions & 1 deletion website/docs/cli/config-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The file can contain all of the options that are [available as CLI flags](./).
"overwrite": true,
"eol": "lf",
"ci": true,
"no-spinner": true
"no-spinner": true,
"omitVersions": false
}
```

Expand All @@ -51,6 +52,7 @@ overwrite: true
eol: lf
ci: true
no-spinner: true
omitVersions: false
```

</TabItem>
Expand All @@ -65,6 +67,7 @@ module.exports = {
eol: "lf",
ci: true,
noSpinner: true,
omitVersions: false,
};
```

Expand Down
12 changes: 12 additions & 0 deletions website/docs/cli/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ Using `--ci` will implicitly set `--no-spinner`.
npx generate-license-file --no-spinner
```

## --omit-versions

<ArgumentInfo type="boolean" />

By default, the CLI includes version numbers in the package names in the generated output file (e.g., "[email protected]").

If you want to omit the version numbers and only include the package names (e.g., "package"), you can provide the `--omit-versions` flag.

```bash
npx generate-license-file --omit-versions
```

## --version

<ArgumentInfo type="boolean" aliases={["-v"]} />
Expand Down
5 changes: 4 additions & 1 deletion website/versioned_docs/version-3.0.0/cli/config-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ The file can contain all of the options that are [available as CLI flags](./).
"overwrite": true,
"eol": "lf",
"ci": true,
"no-spinner": true
"no-spinner": true,
"omitVersions": false
}
```

Expand All @@ -50,6 +51,7 @@ overwrite: true
eol: lf
ci: true
no-spinner: true
omitVersions: false
```

</TabItem>
Expand All @@ -64,6 +66,7 @@ module.exports = {
eol: "lf",
ci: true,
noSpinner: true,
omitVersions: false,
};
```

Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-3.0.0/cli/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ Using `--ci` will implicitly set `--no-spinner`.
npx generate-license-file --no-spinner
```

## --omit-versions

<ArgumentInfo type="boolean" />

By default, the CLI includes version numbers in the package names in the generated output file (e.g., "[email protected]").

If you want to omit the version numbers and only include the package names (e.g., "package"), you can provide the `--omit-versions` flag.

```bash
npx generate-license-file --omit-versions
```

## --version

<ArgumentInfo type="boolean" aliases={["-v"]} />
Expand Down
5 changes: 4 additions & 1 deletion website/versioned_docs/version-4.0.0/cli/config-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The file can contain all of the options that are [available as CLI flags](./).
"overwrite": true,
"eol": "lf",
"ci": true,
"no-spinner": true
"no-spinner": true,
"omitVersions": false
}
```

Expand All @@ -51,6 +52,7 @@ overwrite: true
eol: lf
ci: true
no-spinner: true
omitVersions: false
```

</TabItem>
Expand All @@ -65,6 +67,7 @@ module.exports = {
eol: "lf",
ci: true,
noSpinner: true,
omitVersions: false,
};
```

Expand Down
12 changes: 12 additions & 0 deletions website/versioned_docs/version-4.0.0/cli/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ Using `--ci` will implicitly set `--no-spinner`.
npx generate-license-file --no-spinner
```

## --omit-versions

<ArgumentInfo type="boolean" />

By default, the CLI includes version numbers in the package names in the generated output file (e.g., "[email protected]").

If you want to omit the version numbers and only include the package names (e.g., "package"), you can provide the `--omit-versions` flag.

```bash
npx generate-license-file --omit-versions
```

## --version

<ArgumentInfo type="boolean" aliases={["-v"]} />
Expand Down