diff --git a/README.md b/README.md index a50deee..9c46c39 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ export const metro = object | 'react-native' | File (JavaScript only) export const reactNative = object | File export const drizzle = 'basic' | object | File export const vercel = 'spa' | 'SPA' | 'single-page-application' | 'spa-routes' | 'github-silent' | { extends: 'spa', routes: { ... }} -export const license = 'MIT' | 'mit' | 'public' | 'cc0' | 'commercial' | 'ccby4' | { extends: 'MIT', authors: [{ name: 'Anyone' }, { name: 'Someone', year: 2022 }]} +export const license = 'recommended' | 'MIT' | 'mit' | 'public' | 'cc0' | 'commercial' | 'ccbync4' | { extends: 'MIT', authors: [{ name: 'Anyone' }, { name: 'Someone', year: 2022 }]} export const ignore = true | 'recommended' | 'bundle' | 'numic' | string[] | ['extends:bundle', ...] export const gitignore = // Alias for ignore ``` diff --git a/configuration/license.ts b/configuration/license.ts index dd0a32f..dc9a5e0 100644 --- a/configuration/license.ts +++ b/configuration/license.ts @@ -13,7 +13,7 @@ const getNameFromPackageJson = () => { return state.packageJson.name } -function listAuthors(authors?: { year?: string; name?: string }[]) { +function listAuthors(authors?: ({ year?: string; name?: string } | string)[]) { if (!authors) { return `${new Date().getFullYear()} ${getNameFromPackageJson()}` } @@ -24,7 +24,8 @@ function listAuthors(authors?: { year?: string; name?: string }[]) { } return authors.reduce((acc, author, index) => { - const authorString = `${author.year || new Date().getFullYear()} ${author.name || getNameFromPackageJson()}` + const authorString = + typeof author === 'string' ? author : `${author.year || new Date().getFullYear()} ${author.name || getNameFromPackageJson()}` return acc + (index > 0 ? ', ' : '') + authorString }, '') } @@ -68,39 +69,42 @@ When using or citing the work, you should not imply [endorsement](https://creati [See the legal code](https://creativecommons.org/publicdomain/zero/1.0/legalcode.en)` -// Creative Commons CC0 1.0 UNIVERSAL license, does not waive rights given under the publishing jurisdiction of the author. -const commercialLicense = () => `# ATTRIBUTION 4.0 INTERNATIONAL +// Creative Commons CC BY-NC 4.0 license, contents can be shared with attribution but not used for commercial purposes. +const commercialLicense = () => `# ATTRIBUTION-NONCOMMERCIAL 4.0 INTERNATIONAL ## You are free to: -**Share** — copy and redistribute the material in any medium or format for any purpose, even commercially. +**Share** — copy and redistribute the material in any medium or format -**Adapt** — remix, transform, and build upon the material for any purpose, even commercially. +**Adapt** — remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms. ## Under the following terms: -**Attribution** — You must give [appropriate credit](https://creativecommons.org/licenses/by/4.0/deed.en#ref-appropriate-credit) , provide a link to the license, and [indicate if changes were made](https://creativecommons.org/licenses/by/4.0/deed.en#ref-indicate-changes). You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. +**Attribution** — You must give [appropriate credit](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-appropriate-credit), provide a link to the license, and [indicate if changes were made](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-indicate-changes). You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. + +**NonCommercial** — You may not use the material for [commercial purposes](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-commercial-purposes). -**No additional restrictions** — You may not apply legal terms or [technological measures](https://creativecommons.org/licenses/by/4.0/deed.en#ref-technological-measures) that legally restrict others from doing anything the license permits. +**No additional restrictions** — You may not apply legal terms or [technological measures](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-technological-measures) that legally restrict others from doing anything the license permits. ## Notices: -You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable [exception or limitation](https://creativecommons.org/licenses/by/4.0/deed.en#ref-exception-or-limitation). +You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable [exception or limitation](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-exception-or-limitation). -No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as [publicity, privacy, or moral rights](https://creativecommons.org/licenses/by/4.0/deed.en#ref-publicity-privacy-or-moral-rights) may limit how you use the material. +No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as [publicity, privacy, or moral rights](https://creativecommons.org/licenses/by-nc/4.0/deed.en#ref-publicity-privacy-or-moral-rights) may limit how you use the material. -[See the legal code](https://creativecommons.org/licenses/by/4.0/legalcode.en)` +[See the legal code](https://creativecommons.org/licenses/by-nc/4.0/legalcode.en)` export const templates: Template = { + recommended: mitLicense, mit: mitLicense, // biome-ignore lint/style/useNamingConvention: Alias for upper case typed license. MIT: mitLicense, public: publicDomainLicense, cc0: publicDomainLicense, commercial: commercialLicense, - ccby4: commercialLicense, + ccbync4: commercialLicense, } export function createFile(content: string | object) { diff --git a/package.json b/package.json index a74ea52..372d60a 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,11 @@ "author": "Matthias Giger", "scripts": { "check": "biome check --write .", + "clean": "git clean -fdx test/fixture", "postinstall": "bun index.ts", - "types": "tsc", + "template": "folders 'template/*' 'update --no-install' --output", "test": "bun test ./test/*.test.ts", - "clean": "git clean -fdx test/fixture" + "types": "tsc" }, "dependencies": { "avait": "^1.0.1", diff --git a/template/default/package.json b/template/default/package.json index 43e8793..d761955 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -16,7 +16,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "trustedDependencies": [ "zero-configuration" diff --git a/template/desktop/package.json b/template/desktop/package.json index 85a432e..7118da8 100644 --- a/template/desktop/package.json +++ b/template/desktop/package.json @@ -29,7 +29,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "trustedDependencies": [ "zero-configuration", diff --git a/template/mobile/package.json b/template/mobile/package.json index a11d8da..60447c3 100644 --- a/template/mobile/package.json +++ b/template/mobile/package.json @@ -31,7 +31,7 @@ "numic": "^2.2.0", "react-test-renderer": "^18.3.1", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "trustedDependencies": [ "zero-configuration", diff --git a/template/plugin-bun/package.json b/template/plugin-bun/package.json index 666a36f..2702025 100644 --- a/template/plugin-bun/package.json +++ b/template/plugin-bun/package.json @@ -6,7 +6,7 @@ "devDependencies": { "@biomejs/biome": "^1.8.3", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "peerDependencies": { "typescript": ">= 5" diff --git a/template/plugin-react/package.json b/template/plugin-react/package.json index ee8fccc..810dede 100644 --- a/template/plugin-react/package.json +++ b/template/plugin-react/package.json @@ -7,7 +7,7 @@ "@biomejs/biome": "^1.8.3", "@types/react": "^18.3.3", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "peerDependencies": { "react": ">= 18", diff --git a/template/web/package.json b/template/web/package.json index a90509f..409aaf8 100644 --- a/template/web/package.json +++ b/template/web/package.json @@ -13,7 +13,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "typescript": "^5.5.3", - "zero-configuration": "^0.16.3" + "zero-configuration": "^0.17.0" }, "trustedDependencies": [ "zero-configuration" diff --git a/test/basic.test.ts b/test/basic.test.ts index 82f56ae..f2e1f8f 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -123,7 +123,7 @@ test('Empty project will exit and not add default gitignore.', () => { expect(existsSync(join(fixturePath, '.gitignore'))).toBe(false) }) -test('Creates configuration files for various build-tool configurations.', () => { +test('Creates configuration files for various build-tool configurations.', async () => { const fixturePath = './test/fixture/build' execSync('bun ./../../../index.ts', { @@ -135,11 +135,16 @@ test('Creates configuration files for various build-tool configurations.', () => expect(existsSync(join(fixturePath, 'farm.config.ts'))).toBe(true) expect(existsSync(join(fixturePath, 'vite.config.ts'))).toBe(true) expect(existsSync(join(fixturePath, 'tailwind.config.ts'))).toBe(true) + expect(existsSync(join(fixturePath, 'LICENSE.md'))).toBe(true) // Only work with JavaScript configuration or serializable configuration. // Not serializable in this case. expect(existsSync(join(fixturePath, 'next.config.js'))).toBe(false) // JavaScript only, but defined in package.json. expect(existsSync(join(fixturePath, 'postcss.config.ts'))).toBe(true) + + const license = await Bun.file(join(fixturePath, 'LICENSE.md')).text() + + expect(license).toContain('Copyright (c) Supports String, 2099 Even multiple strings!') }) test('Creates configuration files in all workspaces including the root.', async () => { diff --git a/test/fixture/build/configuration.ts b/test/fixture/build/configuration.ts index 03aa1ee..f456f07 100644 --- a/test/fixture/build/configuration.ts +++ b/test/fixture/build/configuration.ts @@ -59,3 +59,5 @@ export const tailwind = { }, plugins: [], } + +export const license = { extends: 'recommended', authors: ["Supports String", "2099 Even multiple strings!"] }