From da223b26d7f3813e752003bded6af3e4fbc7057e Mon Sep 17 00:00:00 2001 From: Bram Borggreve Date: Tue, 12 Dec 2023 19:49:28 +0000 Subject: [PATCH] refactor: move license and readme templates to preset-common --- packages/preset-common/README.md | 34 ++- packages/preset-common/generators.json | 9 + packages/preset-common/package.json | 3 +- .../common-template-generator.spec.ts.snap | 269 ++++++++++++++++++ .../common-template-generator.spec.ts | 34 +++ .../common-template-generator.ts | 22 ++ .../common-template-schema.d.ts | 42 +++ .../common-template-schema.json | 62 ++++ .../files/license/LICENSE.template | 0 .../files/readme/README.md.template | 0 packages/preset-common/src/index.ts | 2 + .../files/workspace-root/vercel.json.template | 4 + .../next-application-generator.ts | 6 +- packages/preset-react/README.md | 3 +- .../react-application-generator.ts | 6 +- .../react-template/react-template-schema.d.ts | 2 +- .../react-template/react-template-schema.json | 2 +- tools/scripts/sync-readmes.ts | 8 +- 18 files changed, 492 insertions(+), 16 deletions(-) create mode 100644 packages/preset-common/generators.json create mode 100644 packages/preset-common/src/generators/common-template/__snapshots__/common-template-generator.spec.ts.snap create mode 100644 packages/preset-common/src/generators/common-template/common-template-generator.spec.ts create mode 100644 packages/preset-common/src/generators/common-template/common-template-generator.ts create mode 100644 packages/preset-common/src/generators/common-template/common-template-schema.d.ts create mode 100644 packages/preset-common/src/generators/common-template/common-template-schema.json rename packages/{preset-react/src/generators/react-template => preset-common/src/generators/common-template}/files/license/LICENSE.template (100%) rename packages/{preset-react/src/generators/react-template => preset-common/src/generators/common-template}/files/readme/README.md.template (100%) create mode 100644 packages/preset-next/src/generators/next-application/files/workspace-root/vercel.json.template diff --git a/packages/preset-common/README.md b/packages/preset-common/README.md index bd2fac8..a620b9a 100644 --- a/packages/preset-common/README.md +++ b/packages/preset-common/README.md @@ -1,7 +1,37 @@ -# preset-common +# @solana-developers/preset-common This library is a preset for [create-solana-dapp](https://npm.im/create-solana-dapp) with shared code for the other -presets. +-presets. + +## Supported generators + +### common-template + +```bash +> NX generate @solana-developers/preset-common:common-template [name] [options,...] + +From: @solana-developers/preset-common (v0.0.1) +Name: common-template + + Generate Common templates + +Options: + --directory [string] + --name [string] + --npmScope The npm scope to use [string] + --template The template to use [string] [choices: + "license", "readme"] + --webName Name of the web application [string] + (overrides name) + --anchor Anchor template to use [string] [choices: "none", + "counter", "hello-world"] + [default: "none"] + --anchorName Anchor project name [string] [default: "anchor"] + --licenseAuthor The author to use in the [string] + license + --preset The preset to use [string] [choices: "next", + "react"] +``` ## More information diff --git a/packages/preset-common/generators.json b/packages/preset-common/generators.json new file mode 100644 index 0000000..8db92db --- /dev/null +++ b/packages/preset-common/generators.json @@ -0,0 +1,9 @@ +{ + "generators": { + "common-template": { + "factory": "./src/generators/common-template/common-template-generator", + "schema": "./src/generators/common-template/common-template-schema.json", + "description": "common-template generator" + } + } +} diff --git a/packages/preset-common/package.json b/packages/preset-common/package.json index 80e0f32..6d995da 100644 --- a/packages/preset-common/package.json +++ b/packages/preset-common/package.json @@ -46,5 +46,6 @@ "name": "Bram Borggreve", "url": "https://github.com/beeman" } - ] + ], + "generators": "./generators.json" } diff --git a/packages/preset-common/src/generators/common-template/__snapshots__/common-template-generator.spec.ts.snap b/packages/preset-common/src/generators/common-template/__snapshots__/common-template-generator.spec.ts.snap new file mode 100644 index 0000000..6888464 --- /dev/null +++ b/packages/preset-common/src/generators/common-template/__snapshots__/common-template-generator.spec.ts.snap @@ -0,0 +1,269 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`common-template generator should generate files for { template: 'license', anchor: 'counter' } template with %s anchor 1`] = ` +{ + "LICENSE": { + "content": [ + "MIT License", + "Copyright (c) 2023 test", + "Permission is hereby granted, free of charge, to any person obtaining a copy", + "of this software and associated documentation files (the "Software"), to deal", + "in the Software without restriction, including without limitation the rights", + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", + "copies of the Software, and to permit persons to whom the Software is", + "furnished to do so, subject to the following conditions:", + "The above copyright notice and this permission notice shall be included in all", + "copies or substantial portions of the Software.", + "THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", + "SOFTWARE.", + ], + "isBinary": false, + "path": "test/LICENSE", + }, +} +`; + +exports[`common-template generator should generate files for { template: 'license', anchor: 'hello-world' } template with %s anchor 1`] = ` +{ + "LICENSE": { + "content": [ + "MIT License", + "Copyright (c) 2023 test", + "Permission is hereby granted, free of charge, to any person obtaining a copy", + "of this software and associated documentation files (the "Software"), to deal", + "in the Software without restriction, including without limitation the rights", + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", + "copies of the Software, and to permit persons to whom the Software is", + "furnished to do so, subject to the following conditions:", + "The above copyright notice and this permission notice shall be included in all", + "copies or substantial portions of the Software.", + "THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", + "SOFTWARE.", + ], + "isBinary": false, + "path": "test/LICENSE", + }, +} +`; + +exports[`common-template generator should generate files for { template: 'license', anchor: 'none' } template with %s anchor 1`] = ` +{ + "LICENSE": { + "content": [ + "MIT License", + "Copyright (c) 2023 test", + "Permission is hereby granted, free of charge, to any person obtaining a copy", + "of this software and associated documentation files (the "Software"), to deal", + "in the Software without restriction, including without limitation the rights", + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", + "copies of the Software, and to permit persons to whom the Software is", + "furnished to do so, subject to the following conditions:", + "The above copyright notice and this permission notice shall be included in all", + "copies or substantial portions of the Software.", + "THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", + "SOFTWARE.", + ], + "isBinary": false, + "path": "test/LICENSE", + }, +} +`; + +exports[`common-template generator should generate files for { template: 'readme', anchor: 'counter' } template with %s anchor 1`] = ` +{ + "README.md": { + "content": [ + "# test", + "This project is generated with the [create-solana-dapp](https://github.com/solana-developers/create-solana-dapp) generator.", + "## Getting Started", + "### Prerequisites", + "- Node v18.18.0 or higher", + "- Rust v1.70.0 or higher", + "- Anchor CLI 0.29.0 or higher", + "- Solana CLI 1.17.0 or higher", + "### Installation", + "#### Clone the repo", + "\`\`\`shell", + "git clone ", + "cd ", + "\`\`\`", + "#### Install Dependencies", + "\`\`\`shell", + "yarn install", + "\`\`\`", + "#### Start the web app", + "\`\`\`", + "yarn dev", + "\`\`\`", + "## Apps", + "### anchor", + "This is a Solana program written in Rust using the Anchor framework.", + "#### Commands", + "You can use any normal anchor commands. Either move to the \`anchor\` directory and run the \`anchor\` command or prefix the command with \`yarn\`, eg: \`yarn anchor\`.", + "#### Sync the program id:", + "Running this command will create a new keypair in the \`anchor/target/deploy\` directory and save the address to the Anchor config file and update the \`declare_id!\` macro in the \`./src/lib.rs\` file of the program.", + "You will manually need to update the constant in \`anchor/lib/counter-exports.ts\` to match the new program id.", + "\`\`\`shell", + "yarn anchor keys sync", + "\`\`\`", + "#### Build the program:", + "\`\`\`shell", + "yarn anchor-build", + "\`\`\`", + "#### Start the test validator with the program deployed:", + "\`\`\`shell", + "yarn anchor-localnet", + "\`\`\`", + "#### Run the tests", + "\`\`\`shell", + "yarn anchor-test", + "\`\`\`", + "#### Deploy to Devnet", + "\`\`\`shell", + "yarn anchor deploy --provider.cluster devnet", + "\`\`\`", + "### web", + "This is a React app that uses the Anchor generated client to interact with the Solana program.", + "#### Commands", + "Start the web app", + "\`\`\`shell", + "yarn dev", + "\`\`\`", + "Build the web app", + "\`\`\`shell", + "yarn build", + "\`\`\`", + ], + "isBinary": false, + "path": "test/README.md", + }, +} +`; + +exports[`common-template generator should generate files for { template: 'readme', anchor: 'hello-world' } template with %s anchor 1`] = ` +{ + "README.md": { + "content": [ + "# test", + "This project is generated with the [create-solana-dapp](https://github.com/solana-developers/create-solana-dapp) generator.", + "## Getting Started", + "### Prerequisites", + "- Node v18.18.0 or higher", + "- Rust v1.70.0 or higher", + "- Anchor CLI 0.29.0 or higher", + "- Solana CLI 1.17.0 or higher", + "### Installation", + "#### Clone the repo", + "\`\`\`shell", + "git clone ", + "cd ", + "\`\`\`", + "#### Install Dependencies", + "\`\`\`shell", + "yarn install", + "\`\`\`", + "#### Start the web app", + "\`\`\`", + "yarn dev", + "\`\`\`", + "## Apps", + "### anchor", + "This is a Solana program written in Rust using the Anchor framework.", + "#### Commands", + "You can use any normal anchor commands. Either move to the \`anchor\` directory and run the \`anchor\` command or prefix the command with \`yarn\`, eg: \`yarn anchor\`.", + "#### Sync the program id:", + "Running this command will create a new keypair in the \`anchor/target/deploy\` directory and save the address to the Anchor config file and update the \`declare_id!\` macro in the \`./src/lib.rs\` file of the program.", + "You will manually need to update the constant in \`anchor/lib/hello-world-exports.ts\` to match the new program id.", + "\`\`\`shell", + "yarn anchor keys sync", + "\`\`\`", + "#### Build the program:", + "\`\`\`shell", + "yarn anchor-build", + "\`\`\`", + "#### Start the test validator with the program deployed:", + "\`\`\`shell", + "yarn anchor-localnet", + "\`\`\`", + "#### Run the tests", + "\`\`\`shell", + "yarn anchor-test", + "\`\`\`", + "#### Deploy to Devnet", + "\`\`\`shell", + "yarn anchor deploy --provider.cluster devnet", + "\`\`\`", + "### web", + "This is a React app that uses the Anchor generated client to interact with the Solana program.", + "#### Commands", + "Start the web app", + "\`\`\`shell", + "yarn dev", + "\`\`\`", + "Build the web app", + "\`\`\`shell", + "yarn build", + "\`\`\`", + ], + "isBinary": false, + "path": "test/README.md", + }, +} +`; + +exports[`common-template generator should generate files for { template: 'readme', anchor: 'none' } template with %s anchor 1`] = ` +{ + "README.md": { + "content": [ + "# test", + "This project is generated with the [create-solana-dapp](https://github.com/solana-developers/create-solana-dapp) generator.", + "## Getting Started", + "### Prerequisites", + "- Node v18.18.0 or higher", + "### Installation", + "#### Clone the repo", + "\`\`\`shell", + "git clone ", + "cd ", + "\`\`\`", + "#### Install Dependencies", + "\`\`\`shell", + "yarn install", + "\`\`\`", + "#### Start the web app", + "\`\`\`", + "yarn dev", + "\`\`\`", + "## Apps", + "### web", + "This is a React app.", + "#### Commands", + "Start the web app", + "\`\`\`shell", + "yarn dev", + "\`\`\`", + "Build the web app", + "\`\`\`shell", + "yarn build", + "\`\`\`", + ], + "isBinary": false, + "path": "test/README.md", + }, +} +`; diff --git a/packages/preset-common/src/generators/common-template/common-template-generator.spec.ts b/packages/preset-common/src/generators/common-template/common-template-generator.spec.ts new file mode 100644 index 0000000..5225254 --- /dev/null +++ b/packages/preset-common/src/generators/common-template/common-template-generator.spec.ts @@ -0,0 +1,34 @@ +import { Tree } from '@nx/devkit' +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing' +import { getRecursiveFileContents } from '../../utils/get-recursive-file-contents' +import { commonTemplateGenerator } from './common-template-generator' +import { CommonTemplateSchema } from './common-template-schema' + +describe('common-template generator', () => { + let tree: Tree + const options: CommonTemplateSchema = { + name: 'test', + template: 'license', + directory: 'test', + anchor: 'none', + anchorName: 'anchor', + npmScope: 'test', + webName: 'test', + } + const templates: CommonTemplateSchema['template'][] = ['license', 'readme'] + const anchor: CommonTemplateSchema['anchor'][] = ['none', 'counter', 'hello-world'] + + const matrix = templates.map((template) => anchor.map((anchor) => ({ template, anchor }))).flat() + process.env['USER'] = 'test' + + beforeEach(() => { + tree = createTreeWithEmptyWorkspace() + }) + + it.each(matrix)('should generate files for %s template with %s anchor', async ({ template, anchor }) => { + await commonTemplateGenerator(tree, { ...options, template, anchor }) + + const contents = getRecursiveFileContents(tree, options.directory) + expect(contents).toMatchSnapshot() + }) +}) diff --git a/packages/preset-common/src/generators/common-template/common-template-generator.ts b/packages/preset-common/src/generators/common-template/common-template-generator.ts new file mode 100644 index 0000000..ecf84d3 --- /dev/null +++ b/packages/preset-common/src/generators/common-template/common-template-generator.ts @@ -0,0 +1,22 @@ +import { generateFiles, Tree } from '@nx/devkit' +import * as path from 'path' +import { genericSubstitutions } from '../../utils/generic-substitutions' +import { CommonTemplateSchema } from './common-template-schema' + +export async function commonTemplateGenerator(tree: Tree, options: CommonTemplateSchema, templatePath: string = '') { + const substitutions = genericSubstitutions({ + anchor: options.anchor, + anchorName: options.anchorName, + licenseAuthor: options.licenseAuthor, + name: options.webName, + npmScope: options.npmScope, + preset: options.preset, + }) + generateFiles(tree, path.join(__dirname, 'files', options.template, templatePath), options.directory, { + ...options, + ...substitutions, + fileNameUnderscore: substitutions.fileName.replace(/-/g, '_'), + }) +} + +export default commonTemplateGenerator diff --git a/packages/preset-common/src/generators/common-template/common-template-schema.d.ts b/packages/preset-common/src/generators/common-template/common-template-schema.d.ts new file mode 100644 index 0000000..245190e --- /dev/null +++ b/packages/preset-common/src/generators/common-template/common-template-schema.d.ts @@ -0,0 +1,42 @@ +/* eslint-disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +/** + * Generate Common templates + */ +export interface CommonTemplateSchema { + name: string; + /** + * Name of the web application (overrides name) + */ + webName: string; + /** + * The preset to use + */ + preset?: "next" | "react"; + directory: string; + /** + * The template to use + */ + template: "license" | "readme"; + /** + * The author to use in the license + */ + licenseAuthor?: string; + /** + * The npm scope to use + */ + npmScope: string; + /** + * Anchor template to use + */ + anchor?: "none" | "counter" | "hello-world"; + /** + * Anchor project name + */ + anchorName?: string; +} diff --git a/packages/preset-common/src/generators/common-template/common-template-schema.json b/packages/preset-common/src/generators/common-template/common-template-schema.json new file mode 100644 index 0000000..fe35de2 --- /dev/null +++ b/packages/preset-common/src/generators/common-template/common-template-schema.json @@ -0,0 +1,62 @@ +{ + "$schema": "http://json-schema.org/schema", + "$id": "CommonTemplateSchema", + "title": "common-template-schema", + "description": "Generate Common templates", + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "", + "$default": { + "$source": "argv", + "index": 0 + }, + "x-prompt": "What name would you like to use?" + }, + "webName": { + "type": "string", + "description": "Name of the web application (overrides name)" + }, + "preset": { + "type": "string", + "description": "The preset to use", + "enum": ["next", "react"] + }, + "directory": { + "type": "string", + "description": "", + "$default": { + "$source": "argv", + "index": 1 + }, + "x-prompt": "What is the directory directory?" + }, + "template": { + "type": "string", + "enum": ["license", "readme"], + "description": "The template to use", + "x-prompt": "Which template would you like to use?" + }, + "licenseAuthor": { + "type": "string", + "description": "The author to use in the license" + }, + "npmScope": { + "type": "string", + "description": "The npm scope to use" + }, + "anchor": { + "type": "string", + "description": "Anchor template to use", + "enum": ["none", "counter", "hello-world"], + "default": "none" + }, + "anchorName": { + "type": "string", + "description": "Anchor project name", + "default": "anchor" + } + }, + "required": ["name", "directory", "template", "npmScope", "webName"] +} diff --git a/packages/preset-react/src/generators/react-template/files/license/LICENSE.template b/packages/preset-common/src/generators/common-template/files/license/LICENSE.template similarity index 100% rename from packages/preset-react/src/generators/react-template/files/license/LICENSE.template rename to packages/preset-common/src/generators/common-template/files/license/LICENSE.template diff --git a/packages/preset-react/src/generators/react-template/files/readme/README.md.template b/packages/preset-common/src/generators/common-template/files/readme/README.md.template similarity index 100% rename from packages/preset-react/src/generators/react-template/files/readme/README.md.template rename to packages/preset-common/src/generators/common-template/files/readme/README.md.template diff --git a/packages/preset-common/src/index.ts b/packages/preset-common/src/index.ts index 7dea825..003abe9 100644 --- a/packages/preset-common/src/index.ts +++ b/packages/preset-common/src/index.ts @@ -1,3 +1,5 @@ +export * from './generators/common-template/common-template-generator' +export * from './generators/common-template/common-template-schema' export * from './utils/generic-substitutions' export * from './utils/application-cleanup' export * from './utils/get-recursive-file-contents' diff --git a/packages/preset-next/src/generators/next-application/files/workspace-root/vercel.json.template b/packages/preset-next/src/generators/next-application/files/workspace-root/vercel.json.template new file mode 100644 index 0000000..2c68dbf --- /dev/null +++ b/packages/preset-next/src/generators/next-application/files/workspace-root/vercel.json.template @@ -0,0 +1,4 @@ +{ + "buildCommand": "npm run build", + "outputDirectory": "dist/web/.next" +} diff --git a/packages/preset-next/src/generators/next-application/next-application-generator.ts b/packages/preset-next/src/generators/next-application/next-application-generator.ts index 77bff6f..a4be6af 100644 --- a/packages/preset-next/src/generators/next-application/next-application-generator.ts +++ b/packages/preset-next/src/generators/next-application/next-application-generator.ts @@ -8,7 +8,7 @@ import { } from '@nx/devkit' import { getNpmScope } from '@nx/js/src/utils/package-json/get-npm-scope' import { anchorApplicationGenerator } from '@solana-developers/preset-anchor' -import { applicationCleanup, packageVersion } from '@solana-developers/preset-common' +import { applicationCleanup, commonTemplateGenerator, packageVersion } from '@solana-developers/preset-common' import { applicationTailwindConfig, reactApplicationDependencies, @@ -164,7 +164,7 @@ export default function Page() { }) // Generate the readme files - await reactTemplateGenerator(tree, { + await commonTemplateGenerator(tree, { name: options.webName, npmScope, template: 'readme', @@ -175,7 +175,7 @@ export default function Page() { }) // Generate the license files - await reactTemplateGenerator(tree, { + await commonTemplateGenerator(tree, { name: options.webName, npmScope, template: 'license', diff --git a/packages/preset-react/README.md b/packages/preset-react/README.md index e2cdbbc..e8be7bf 100644 --- a/packages/preset-react/README.md +++ b/packages/preset-react/README.md @@ -46,8 +46,7 @@ Options: --npmScope The npm scope to use [string] --template The template to use [string] [choices: "anchor-counter", "base", - "license", "none", "readme", - "solana-provider", + "none", "solana-provider", "tailwind"] --webName Name of the web application [string] (overrides name) diff --git a/packages/preset-react/src/generators/react-application/react-application-generator.ts b/packages/preset-react/src/generators/react-application/react-application-generator.ts index 0172e84..d3bace5 100644 --- a/packages/preset-react/src/generators/react-application/react-application-generator.ts +++ b/packages/preset-react/src/generators/react-application/react-application-generator.ts @@ -1,7 +1,7 @@ import { formatFiles, getProjects, installPackagesTask, Tree, updateJson } from '@nx/devkit' import { getNpmScope } from '@nx/js/src/utils/package-json/get-npm-scope' import { anchorApplicationGenerator } from '@solana-developers/preset-anchor' -import { applicationCleanup } from '@solana-developers/preset-common' +import { applicationCleanup, commonTemplateGenerator } from '@solana-developers/preset-common' import { join } from 'path' import { applicationTailwindConfig, @@ -102,7 +102,7 @@ export async function reactApplicationGenerator(tree: Tree, rawOptions: ReactApp }) // Generate the readme files - await reactTemplateGenerator(tree, { + await commonTemplateGenerator(tree, { name: options.webName, npmScope, template: 'readme', @@ -113,7 +113,7 @@ export async function reactApplicationGenerator(tree: Tree, rawOptions: ReactApp }) // Generate the license files - await reactTemplateGenerator(tree, { + await commonTemplateGenerator(tree, { name: options.webName, npmScope, template: 'license', diff --git a/packages/preset-react/src/generators/react-template/react-template-schema.d.ts b/packages/preset-react/src/generators/react-template/react-template-schema.d.ts index 258978d..1ef1778 100644 --- a/packages/preset-react/src/generators/react-template/react-template-schema.d.ts +++ b/packages/preset-react/src/generators/react-template/react-template-schema.d.ts @@ -22,7 +22,7 @@ export interface ReactTemplateSchema { /** * The template to use */ - template: "anchor-counter" | "base" | "license" | "none" | "readme" | "solana-provider" | "tailwind"; + template: "anchor-counter" | "base" | "none" | "solana-provider" | "tailwind"; /** * The author to use in the license */ diff --git a/packages/preset-react/src/generators/react-template/react-template-schema.json b/packages/preset-react/src/generators/react-template/react-template-schema.json index 415ccc0..78fe588 100644 --- a/packages/preset-react/src/generators/react-template/react-template-schema.json +++ b/packages/preset-react/src/generators/react-template/react-template-schema.json @@ -34,7 +34,7 @@ }, "template": { "type": "string", - "enum": ["anchor-counter", "base", "license", "none", "readme", "solana-provider", "tailwind"], + "enum": ["anchor-counter", "base", "none", "solana-provider", "tailwind"], "description": "The template to use", "x-prompt": "Which template would you like to use?" }, diff --git a/tools/scripts/sync-readmes.ts b/tools/scripts/sync-readmes.ts index aae1b72..34e2689 100644 --- a/tools/scripts/sync-readmes.ts +++ b/tools/scripts/sync-readmes.ts @@ -127,13 +127,15 @@ ${defaultFooter()}` main() -export function defaultDescription(pkg: 'preset-anchor' | 'preset-next' | 'preset-react') { - const template = (library: string) => - `This library is a preset for [create-solana-dapp](https://npm.im/create-solana-dapp) that adds ${library} support to your project.` +export function defaultDescription(pkg: 'preset-anchor' | 'preset-common' | 'preset-next' | 'preset-react') { + const base = 'This library is a preset for [create-solana-dapp](https://npm.im/create-solana-dapp)' + const template = (library: string) => `${base} that adds ${library} support to your project.` switch (pkg) { case 'preset-anchor': return template('[Anchor](https://www.anchor-lang.com/)') + case 'preset-common': + return `${base} with shared code for the other -presets.` case 'preset-next': return template('[Next.js](https://nextjs.org/)') case 'preset-react':