From 1f0ff75525dafa671217fbfa5e7972258c3937c4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 8 Mar 2024 14:19:34 +0530 Subject: [PATCH 1/3] add packagesToInstall and packagesToRemove to CLI --- examples/data-exchange/tsconfig.json | 26 +++++++-------------- examples/drr/tsconfig.json | 24 +++++++------------ package-lock.json | 5 +--- package.json | 1 - packages/create-opub-app/create-app.ts | 16 +++++++++++-- packages/create-opub-app/utils/constants.ts | 22 +++++++++++++---- packages/opub-ui/package.json | 3 ++- 7 files changed, 52 insertions(+), 45 deletions(-) diff --git a/examples/data-exchange/tsconfig.json b/examples/data-exchange/tsconfig.json index b5455358..c54c8168 100644 --- a/examples/data-exchange/tsconfig.json +++ b/examples/data-exchange/tsconfig.json @@ -1,20 +1,6 @@ { + "extends": "@repo/config-ts/example.json", "compilerOptions": { - "target": "ESNext", - "lib": ["dom", "dom.iterable", "esnext"], - "downlevelIteration": true, - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "ESNext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, "plugins": [ { "name": "next" @@ -25,6 +11,12 @@ "@/*": ["./*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules", "gql"] + "include": [ + "next-env.d.ts", + "next.config.js", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": ["node_modules"] } diff --git a/examples/drr/tsconfig.json b/examples/drr/tsconfig.json index 68fd2c44..c54c8168 100644 --- a/examples/drr/tsconfig.json +++ b/examples/drr/tsconfig.json @@ -1,20 +1,6 @@ { + "extends": "@repo/config-ts/example.json", "compilerOptions": { - "target": "ESNext", - "lib": ["dom", "dom.iterable", "esnext"], - "downlevelIteration": true, - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "ESNext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, "plugins": [ { "name": "next" @@ -25,6 +11,12 @@ "@/*": ["./*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "next.config.js", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], "exclude": ["node_modules"] } diff --git a/package-lock.json b/package-lock.json index 0da1ec21..a1b9719e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ ], "devDependencies": { "@changesets/cli": "^2.26.1", - "autoprefixer": "^10.4.14", "husky": "^8.0.0", "lint-staged": "^13.2.0", "new-component-opub": "git+https://github.com/CivicDataLab/new-component.git", @@ -13988,7 +13987,6 @@ "version": "10.4.18", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.18.tgz", "integrity": "sha512-1DKbDfsr6KUElM6wg+0zRNkB/Q7WcKYAaK+pzXn+Xqmszm/5Xa9coeNdtP88Vi+dPzZnMjhge8GIV49ZQkDa+g==", - "dev": true, "funding": [ { "type": "opencollective", @@ -18213,7 +18211,6 @@ "version": "4.3.7", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", - "dev": true, "engines": { "node": "*" }, @@ -22525,7 +22522,6 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -31525,6 +31521,7 @@ "@react-types/shared": "^3.18.0", "@tabler/icons-react": "^2.17.0", "@tanstack/react-table": "^8.9.1", + "autoprefixer": "^10.4.18", "clsx": "^2.1.0", "cmdk": "^0.2.0", "echarts": "^5.4.3", diff --git a/package.json b/package.json index e22db943..356a341d 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ }, "devDependencies": { "@changesets/cli": "^2.26.1", - "autoprefixer": "^10.4.14", "husky": "^8.0.0", "lint-staged": "^13.2.0", "new-component-opub": "git+https://github.com/CivicDataLab/new-component.git", diff --git a/packages/create-opub-app/create-app.ts b/packages/create-opub-app/create-app.ts index 6d12f218..73b4d5d8 100644 --- a/packages/create-opub-app/create-app.ts +++ b/packages/create-opub-app/create-app.ts @@ -3,6 +3,7 @@ import path from 'path'; import retry from 'async-retry'; import fse from 'fs-extra'; +import { packagesToInstall, packagesToRemove } from './utils/constants'; import { initializeGit } from './utils/git'; import { install } from './utils/install'; import { colors, logger } from './utils/logger'; @@ -69,8 +70,19 @@ export async function createApp({ // update the project name in package json const appName = path.basename(root); pkgJson.name = appName; - // add opub-ui as a dependency - pkgJson.dependencies['opub-ui'] = 'latest'; + + // add the packages to install + Object.keys(packagesToInstall).forEach((type: any) => { + Object.keys(packagesToInstall[type]).forEach((pkg) => { + pkgJson[type][pkg] = packagesToInstall[type][pkg]; + }); + }); + + // remove the packages from devDependencies + packagesToRemove.forEach((pkg) => { + delete pkgJson.devDependencies[pkg]; + }); + fse.writeJSONSync(packageJsonPath, pkgJson, { spaces: 2, }); diff --git a/packages/create-opub-app/utils/constants.ts b/packages/create-opub-app/utils/constants.ts index edec692d..a8267ed9 100644 --- a/packages/create-opub-app/utils/constants.ts +++ b/packages/create-opub-app/utils/constants.ts @@ -24,12 +24,26 @@ export const managers: { bun: 'Bun', }; -const packagesToInstall = { - 'create-opub-app': 'latest', - 'opub-mono': 'latest', - 'opub-mono-cli': 'latest', +export const packagesToInstall: { + [key: string]: { + [key: string]: string; + }; +} = { + dependencies: { + 'opub-ui': 'latest', + }, + devDependencies: { + 'opub-tokens': 'latest', + typescript: '^5.0.4', + }, }; +export const packagesToRemove = [ + '@repo/config-ts', + '@repo/eslint-config', + '@repo/prettier-config', +]; + export const TITLE_TEXT = ` ____ _ ___ ____ _ _ / ___|_ __ ___ __ _| |_ ___ / _ \\| _ \\ _ _| |__ / \\ _ __ _ __ | | | '__/ _ \\/ \_\` | __/ _ \\ | | | | |_) | | | | '_ \\ / _ \\ | '_ \\| '_ \\ diff --git a/packages/opub-ui/package.json b/packages/opub-ui/package.json index 233fea9a..29a35788 100644 --- a/packages/opub-ui/package.json +++ b/packages/opub-ui/package.json @@ -1,7 +1,7 @@ { "name": "opub-ui", "description": "OPub UI Library", - "version": "0.3.2", + "version": "0.3.3", "private": false, "license": "MIT", "author": "CivicDataLab ", @@ -89,6 +89,7 @@ "@react-types/shared": "^3.18.0", "@tabler/icons-react": "^2.17.0", "@tanstack/react-table": "^8.9.1", + "autoprefixer": "^10.4.18", "clsx": "^2.1.0", "cmdk": "^0.2.0", "echarts": "^5.4.3", From 79a14d2c8d1c9c3578888ee23f37ff3408f2173d Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 8 Mar 2024 14:53:39 +0530 Subject: [PATCH 2/3] add sync-config script --- examples/data-exchange/.eslintrc.js | 20 +++++++++++ examples/data-exchange/.eslintrc.json | 4 --- examples/data-exchange/.prettierrc.js | 33 +++++++++++++++++ examples/data-exchange/.prettierrc.json | 1 - examples/data-exchange/tsconfig.json | 48 ++++++++++++++----------- examples/district/.eslintrc.js | 20 +++++++++++ examples/district/.eslintrc.json | 4 --- examples/district/.prettierrc.js | 33 +++++++++++++++++ examples/district/.prettierrc.json | 1 - examples/district/tsconfig.json | 48 ++++++++++++++----------- examples/drr/.eslintrc.js | 20 +++++++++++ examples/drr/.eslintrc.json | 4 --- examples/drr/.prettierrc.js | 33 +++++++++++++++++ examples/drr/.prettierrc.json | 1 - examples/drr/lib/api.ts | 15 ++++---- examples/drr/tsconfig.json | 48 ++++++++++++++----------- package.json | 3 +- packages/create-opub-app/create-app.ts | 1 + utils/sync-config.js | 33 +++++++++++++++++ 19 files changed, 285 insertions(+), 85 deletions(-) create mode 100644 examples/data-exchange/.eslintrc.js delete mode 100644 examples/data-exchange/.eslintrc.json create mode 100644 examples/data-exchange/.prettierrc.js delete mode 100644 examples/data-exchange/.prettierrc.json create mode 100644 examples/district/.eslintrc.js delete mode 100644 examples/district/.eslintrc.json create mode 100644 examples/district/.prettierrc.js delete mode 100644 examples/district/.prettierrc.json create mode 100644 examples/drr/.eslintrc.js delete mode 100644 examples/drr/.eslintrc.json create mode 100644 examples/drr/.prettierrc.js delete mode 100644 examples/drr/.prettierrc.json create mode 100644 utils/sync-config.js diff --git a/examples/data-exchange/.eslintrc.js b/examples/data-exchange/.eslintrc.js new file mode 100644 index 00000000..580c14e7 --- /dev/null +++ b/examples/data-exchange/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'next', + 'prettier', + ], + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['warn'], + '@typescript-eslint/no-explicit-any': ['off'], + 'react/display-name': 'off', + '@next/next/no-html-link-for-pages': 'off', + 'prefer-const': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@next/next/no-img-element': 'off', + }, + ignorePatterns: ['**/generated/**/*.ts', 'node_modules/', 'dist/'], +} diff --git a/examples/data-exchange/.eslintrc.json b/examples/data-exchange/.eslintrc.json deleted file mode 100644 index 4207d43b..00000000 --- a/examples/data-exchange/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["@repo/eslint-config/next.js"] -} diff --git a/examples/data-exchange/.prettierrc.js b/examples/data-exchange/.prettierrc.js new file mode 100644 index 00000000..c7460087 --- /dev/null +++ b/examples/data-exchange/.prettierrc.js @@ -0,0 +1,33 @@ +module.exports = { + endOfLine: 'lf', + semi: true, + trailingComma: 'es5', + printWidth: 80, + tabWidth: 2, + useTabs: false, + singleQuote: true, + importOrder: [ + '^(react/(.*)$)|^(react$)', + '^(next/(.*)$)|^(next$)', + '', + '', + '^types$', + '^@local/(.*)$', + '^@/config/(.*)$', + '^@/lib/(.*)$', + '^@/components/(.*)$', + '^@/styles/(.*)$', + '^[./]', + ], + importOrderSeparation: false, + importOrderSortSpecifiers: true, + importOrderBuiltinModulesToTop: true, + importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], + importOrderMergeDuplicateImports: true, + importOrderCombineTypeAndValueImports: true, + plugins: [ + '@ianvs/prettier-plugin-sort-imports', + 'prettier-plugin-tailwindcss', + ], + tailwindFunctions: ['clsx', 'cn'], +}; diff --git a/examples/data-exchange/.prettierrc.json b/examples/data-exchange/.prettierrc.json deleted file mode 100644 index fe5b9165..00000000 --- a/examples/data-exchange/.prettierrc.json +++ /dev/null @@ -1 +0,0 @@ -"@repo/prettier-config" \ No newline at end of file diff --git a/examples/data-exchange/tsconfig.json b/examples/data-exchange/tsconfig.json index c54c8168..6d9a5c7a 100644 --- a/examples/data-exchange/tsconfig.json +++ b/examples/data-exchange/tsconfig.json @@ -1,22 +1,30 @@ { - "extends": "@repo/config-ts/example.json", - "compilerOptions": { - "plugins": [ - { - "name": "next" - } - ], - "baseUrl": ".", - "paths": { - "@/*": ["./*"] - } - }, - "include": [ - "next-env.d.ts", - "next.config.js", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules"] + "compilerOptions": { + "target": "ESNext", + "lib": ["dom", "dom.iterable", "esnext"], + "downlevelIteration": true, + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "plugins": [ + { + "name": "next" + } + ], + "baseUrl": ".", + "paths": { + "@/*": ["./*"] + } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] } diff --git a/examples/district/.eslintrc.js b/examples/district/.eslintrc.js new file mode 100644 index 00000000..580c14e7 --- /dev/null +++ b/examples/district/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'next', + 'prettier', + ], + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['warn'], + '@typescript-eslint/no-explicit-any': ['off'], + 'react/display-name': 'off', + '@next/next/no-html-link-for-pages': 'off', + 'prefer-const': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@next/next/no-img-element': 'off', + }, + ignorePatterns: ['**/generated/**/*.ts', 'node_modules/', 'dist/'], +} diff --git a/examples/district/.eslintrc.json b/examples/district/.eslintrc.json deleted file mode 100644 index 4207d43b..00000000 --- a/examples/district/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["@repo/eslint-config/next.js"] -} diff --git a/examples/district/.prettierrc.js b/examples/district/.prettierrc.js new file mode 100644 index 00000000..c7460087 --- /dev/null +++ b/examples/district/.prettierrc.js @@ -0,0 +1,33 @@ +module.exports = { + endOfLine: 'lf', + semi: true, + trailingComma: 'es5', + printWidth: 80, + tabWidth: 2, + useTabs: false, + singleQuote: true, + importOrder: [ + '^(react/(.*)$)|^(react$)', + '^(next/(.*)$)|^(next$)', + '', + '', + '^types$', + '^@local/(.*)$', + '^@/config/(.*)$', + '^@/lib/(.*)$', + '^@/components/(.*)$', + '^@/styles/(.*)$', + '^[./]', + ], + importOrderSeparation: false, + importOrderSortSpecifiers: true, + importOrderBuiltinModulesToTop: true, + importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], + importOrderMergeDuplicateImports: true, + importOrderCombineTypeAndValueImports: true, + plugins: [ + '@ianvs/prettier-plugin-sort-imports', + 'prettier-plugin-tailwindcss', + ], + tailwindFunctions: ['clsx', 'cn'], +}; diff --git a/examples/district/.prettierrc.json b/examples/district/.prettierrc.json deleted file mode 100644 index fe5b9165..00000000 --- a/examples/district/.prettierrc.json +++ /dev/null @@ -1 +0,0 @@ -"@repo/prettier-config" \ No newline at end of file diff --git a/examples/district/tsconfig.json b/examples/district/tsconfig.json index c54c8168..6d9a5c7a 100644 --- a/examples/district/tsconfig.json +++ b/examples/district/tsconfig.json @@ -1,22 +1,30 @@ { - "extends": "@repo/config-ts/example.json", - "compilerOptions": { - "plugins": [ - { - "name": "next" - } - ], - "baseUrl": ".", - "paths": { - "@/*": ["./*"] - } - }, - "include": [ - "next-env.d.ts", - "next.config.js", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules"] + "compilerOptions": { + "target": "ESNext", + "lib": ["dom", "dom.iterable", "esnext"], + "downlevelIteration": true, + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "plugins": [ + { + "name": "next" + } + ], + "baseUrl": ".", + "paths": { + "@/*": ["./*"] + } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] } diff --git a/examples/drr/.eslintrc.js b/examples/drr/.eslintrc.js new file mode 100644 index 00000000..580c14e7 --- /dev/null +++ b/examples/drr/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'next', + 'prettier', + ], + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['warn'], + '@typescript-eslint/no-explicit-any': ['off'], + 'react/display-name': 'off', + '@next/next/no-html-link-for-pages': 'off', + 'prefer-const': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@next/next/no-img-element': 'off', + }, + ignorePatterns: ['**/generated/**/*.ts', 'node_modules/', 'dist/'], +} diff --git a/examples/drr/.eslintrc.json b/examples/drr/.eslintrc.json deleted file mode 100644 index 4207d43b..00000000 --- a/examples/drr/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["@repo/eslint-config/next.js"] -} diff --git a/examples/drr/.prettierrc.js b/examples/drr/.prettierrc.js new file mode 100644 index 00000000..c7460087 --- /dev/null +++ b/examples/drr/.prettierrc.js @@ -0,0 +1,33 @@ +module.exports = { + endOfLine: 'lf', + semi: true, + trailingComma: 'es5', + printWidth: 80, + tabWidth: 2, + useTabs: false, + singleQuote: true, + importOrder: [ + '^(react/(.*)$)|^(react$)', + '^(next/(.*)$)|^(next$)', + '', + '', + '^types$', + '^@local/(.*)$', + '^@/config/(.*)$', + '^@/lib/(.*)$', + '^@/components/(.*)$', + '^@/styles/(.*)$', + '^[./]', + ], + importOrderSeparation: false, + importOrderSortSpecifiers: true, + importOrderBuiltinModulesToTop: true, + importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], + importOrderMergeDuplicateImports: true, + importOrderCombineTypeAndValueImports: true, + plugins: [ + '@ianvs/prettier-plugin-sort-imports', + 'prettier-plugin-tailwindcss', + ], + tailwindFunctions: ['clsx', 'cn'], +}; diff --git a/examples/drr/.prettierrc.json b/examples/drr/.prettierrc.json deleted file mode 100644 index fe5b9165..00000000 --- a/examples/drr/.prettierrc.json +++ /dev/null @@ -1 +0,0 @@ -"@repo/prettier-config" \ No newline at end of file diff --git a/examples/drr/lib/api.ts b/examples/drr/lib/api.ts index dd33719a..c0d38661 100644 --- a/examples/drr/lib/api.ts +++ b/examples/drr/lib/api.ts @@ -1,8 +1,9 @@ -import { gqlConfig } from '@/config/site'; +import React from 'react'; import { type TypedDocumentNode } from '@graphql-typed-document-node/core'; import { QueryClient, useQuery } from '@tanstack/react-query'; import { request } from 'graphql-request'; -import React from 'react'; + +import { gqlConfig } from '@/config/site'; // create a wrapper function for graphql-request // that will be used by react-query @@ -11,13 +12,9 @@ export async function GraphQL( document: TypedDocumentNode, ...[variables]: TVariables extends Record ? [] : [TVariables] ) { - const data = await request( - gqlConfig[type], - document, - { - ...variables, - }, - ); + const data = await request(gqlConfig[type], document, { + ...variables, + }); return data; } diff --git a/examples/drr/tsconfig.json b/examples/drr/tsconfig.json index c54c8168..6d9a5c7a 100644 --- a/examples/drr/tsconfig.json +++ b/examples/drr/tsconfig.json @@ -1,22 +1,30 @@ { - "extends": "@repo/config-ts/example.json", - "compilerOptions": { - "plugins": [ - { - "name": "next" - } - ], - "baseUrl": ".", - "paths": { - "@/*": ["./*"] - } - }, - "include": [ - "next-env.d.ts", - "next.config.js", - "**/*.ts", - "**/*.tsx", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules"] + "compilerOptions": { + "target": "ESNext", + "lib": ["dom", "dom.iterable", "esnext"], + "downlevelIteration": true, + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "plugins": [ + { + "name": "next" + } + ], + "baseUrl": ".", + "paths": { + "@/*": ["./*"] + } + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] } diff --git a/package.json b/package.json index 356a341d..2fe70d4b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "new-component": "new-component", "build:packages": "turbo run build --filter=create-opub-app --filter=opub-ui", "publish": "changeset publish", - "style": "turbo run style" + "style": "turbo run style", + "sync-config": "node ./utils/sync-config.js" }, "devDependencies": { "@changesets/cli": "^2.26.1", diff --git a/packages/create-opub-app/create-app.ts b/packages/create-opub-app/create-app.ts index 73b4d5d8..71709363 100644 --- a/packages/create-opub-app/create-app.ts +++ b/packages/create-opub-app/create-app.ts @@ -83,6 +83,7 @@ export async function createApp({ delete pkgJson.devDependencies[pkg]; }); + // write the changes to package.json fse.writeJSONSync(packageJsonPath, pkgJson, { spaces: 2, }); diff --git a/utils/sync-config.js b/utils/sync-config.js new file mode 100644 index 00000000..be86b21d --- /dev/null +++ b/utils/sync-config.js @@ -0,0 +1,33 @@ +const fs = require('fs').promises + +const configPaths = { + eslint: 'config-eslint/next.js', + prettier: 'config-prettier/index.js', + tsconfig: 'config-ts/example.json', +} + +const pastePath = { + eslint: '.eslintrc.js', + prettier: '.prettierrc.js', + tsconfig: 'tsconfig.json', +} + +const copyConfig = async (config) => { + const base = process.cwd() + const source = `${base}/packages/${configPaths[config]}` + + // get all directories in base/examples + await fs.readdir(`${base}/examples`).then((dirs) => { + dirs.forEach((dir) => { + const destination = `${base}/examples/${dir}/${pastePath[config]}` + fs.copyFile(source, destination) + console.log(`${config} copied to ${dir}`) + }) + }) +} + +const syncConfig = async () => { + await Promise.all(Object.keys(configPaths).map(copyConfig)) +} + +syncConfig() From 91e2949c90bbf2a5d1148e37e95a48156d682aa2 Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 8 Mar 2024 14:54:47 +0530 Subject: [PATCH 3/3] Bump version to 0.1.6 --- packages/create-opub-app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-opub-app/package.json b/packages/create-opub-app/package.json index 0246f533..0799b788 100644 --- a/packages/create-opub-app/package.json +++ b/packages/create-opub-app/package.json @@ -1,6 +1,6 @@ { "name": "create-opub-app", - "version": "0.1.5", + "version": "0.1.6", "publishConfig": { "access": "public" },