create-layer
Advanced tools
Comparing version 1.0.4 to 1.0.5
#!/usr/bin/env node | ||
(()=>{"use strict";var e={474:(e,n,t)=>{var r=t(834),s=t(431),o=t(604),i=t(217),a=t(127);const p=JSON.parse('{"presets":["@babel/preset-env","@babel/preset-typescript"]}'),l=JSON.parse('{"env":{"node":true,"es6":true},"settings":{"import/resolver":{"typescript":{}}},"parser":"@typescript-eslint/parser","parserOptions":{"project":"tsconfig.json","tsconfigRootDir":"."},"plugins":["prettier","import","@typescript-eslint"],"extends":["prettier","eslint:recommended","plugin:prettier/recommended","plugin:import/errors","plugin:@typescript-eslint/recommended"],"rules":{"prettier/prettier":2,"import/first":2,"import/newline-after-import":2,"import/order":[2,{"pathGroups":[{"pattern":"@*/**","group":"parent"},{"pattern":".*/**","group":"sibling"}],"newlines-between":"always"}],"no-else-return":2,"no-return-await":2,"camelcase":2,"no-return-assign":2,"prefer-destructuring":[2,{"object":true,"array":false}],"curly":[2,"all"],"no-unused-expressions":2,"object-shorthand":[2,"always",{"avoidQuotes":true,"avoidExplicitReturnArrows":true}],"no-await-in-loop":2,"no-loss-of-precision":2,"no-promise-executor-return":2,"no-useless-backreference":2,"array-callback-return":2,"consistent-return":2,"dot-notation":2,"no-extend-native":2,"no-lone-blocks":2,"no-multi-str":2,"no-proto":2,"require-await":2,"prefer-template":2,"prefer-arrow-callback":2,"arrow-body-style":2,"max-len":[2,{"code":80}],"padding-line-between-statements":["error",{"blankLine":"always","prev":"*","next":"return"},{"blankLine":"always","prev":"*","next":["multiline-block-like","multiline-const","multiline-let"]},{"blankLine":"always","prev":["multiline-block-like","multiline-const","multiline-let"],"next":"*"},{"blankLine":"always","prev":"singleline-const","next":"*"},{"blankLine":"always","prev":"singleline-let","next":"*"},{"blankLine":"always","prev":"*","next":"singleline-const"},{"blankLine":"always","prev":"*","next":"singleline-let"},{"blankLine":"any","prev":"singleline-let","next":"singleline-let"},{"blankLine":"any","prev":"singleline-const","next":"singleline-const"}]}}'),c=JSON.parse('{"semi":false,"singleQuote":true,"arrowParens":"avoid","quoteProps":"consistent"}');var d=t(296),m=t(504);const u=JSON.parse('{"private":true,"scripts":{"test":"jest","ts":"tsc --noemit","lint":"eslint . --ext .ts --fix","format-json":"prettier **/*.json .*rc --write"},"devDependencies":{"@babel/core":"^7.13.15","@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@types/jest":"^26.0.22","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","babel-jest":"^26.6.3","eslint":"^7.24.0","eslint-config-prettier":"^8.2.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.4.0","jest":"^26.6.3","prettier":"^2.2.1","ts-node":"^9.1.1","typescript":"^4.2.4"}}'),g=JSON.parse('{"compilerOptions":{"strict":true,"target":"esnext","lib":["esnext"],"moduleResolution":"node","esModuleInterop":true,"resolveJsonModule":true,"skipLibCheck":true,"typeRoots":["node_modules/@types","index.d.ts"],"baseUrl":"src","paths":{"@/*":["./*"]}}}');var f=t(362),v=t(630),x=t(836);const b=()=>({scaffold:{".idea/inspectionProfiles/Project_Default.xml":r,".idea/jsLinters/eslint.xml":s,".idea/watcherTasks.xml":o,".vscode/settings.json":i,"dev-helpers/alias.ts":a,".babelrc":p,".eslintrc":l,".prettierrc":c,".gitignore":d,"index.d.ts":"","jest.config.ts":m,"package.json":u,"tsconfig.json":g},getSrc:()=>({"array-sum.ts":f,"array-sum.spec.ts":v}),getReadme:()=>x}),y=e=>e.scaffold["package.json"],h=e=>e.scaffold["tsconfig.json"].compilerOptions;var w=t(110),k=t(856),j=t(510),P=t(233),R=t(130),S=t(551),$=t(906),C=t(887);const O=(e,n)=>C.replace("{{ title }}",e).replace("{{ body }}",n);var D=t(901),F=t(872),A=t(642),L=t(285),J=t(986),M=t(556),_=t(402),N=t(191),q=t(247);const E=()=>{const e=b(),n=h(e),t=y(e),{scripts:r,devDependencies:s}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]=D,r["format-scss"]="prettier **/*.scss --write",r.build="webpack",r.serve="webpack serve",t.devDependencies={...s,webpack:"^5.28.0","webpack-cli":"^4.6.0","webpack-dev-server":"^3.11.2","babel-loader":"^8.2.2","css-loader":"^5.2.0","sass-loader":"^11.0.1","style-loader":"^2.0.0","mini-css-extract-plugin":"^1.4.0",sass:"^1.32.8","html-webpack-plugin":"^5.3.1","clean-webpack-plugin":"^3.0.0","copy-webpack-plugin":"^8.1.0","@types/mini-css-extract-plugin":"^1.4.1","@types/copy-webpack-plugin":"^6.4.1"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":F,"dev-helpers/webpack-prod.ts":A,"webpack.config.ts":L},getSrc:()=>({"favicon.svg":J,"index.html":O("Frontend",M),"main.scss":_,"main.ts":N,"array-sum.ts":f,"array-sum.spec.ts":v}),getReadme:()=>q}};var U=t(450),T=t(235),z=t(532);const B={code:b,backend:()=>{const e=b(),n=y(e),{scripts:t,devDependencies:r}=n;return t.build="webpack && ts-node dev-helpers/create-package.ts",t.start="node dist",n.devDependencies={...r,"@types/node":"^14.14.39",webpack:"^5.28.0","webpack-cli":"^4.6.0","babel-loader":"^8.2.2"},{scaffold:{...e.scaffold,"dev-helpers/dependencies.ts":w,"dev-helpers/create-package.ts":k,"webpack.config.ts":j},getSrc:()=>({"main.ts":P,"app.ts":R,"app.spec.ts":S}),getReadme:()=>$}},frontend:E,react:()=>{const e=E(),n=h(e),t="webpack.config.ts",r="'@babel/preset-typescript'",s=`'@babel/preset-react', ${r}`,o=e.scaffold[t];return(e=>{const n=e.scaffold[".babelrc"],t=n.presets.pop();n.presets.push("@babel/preset-react"),n.presets.push(t)})(e),(e=>{const n=y(e),{devDependencies:t,scripts:r}=n;r.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@types/react":"^17.0.3","@types/react-dom":"^17.0.3","@babel/preset-react":"^7.13.13","eslint-plugin-react":"^7.23.1"},n.dependencies={react:"^17.0.2","react-dom":"^17.0.2"}})(e),(e=>{const n=(e=>e.scaffold[".eslintrc"])(e);n.extends.push("plugin:react/recommended"),n.settings.react={version:"detect"},n.rules={...n.rules,"react/jsx-uses-vars":2,"react/jsx-boolean-value":2,"react/self-closing-comp":2,"react/jsx-fragments":2}})(e),e.scaffold[t]=o.replace("'.ts'","'.ts', '.tsx'").replace(".ts$",".tsx?$").replace(r,s),n.jsx="react",{scaffold:e.scaffold,getSrc:()=>({"App.tsx":U,"main.ts":T,"main.scss":_,"favicon.svg":J,"index.html":O("React",'<div id="react-root"></div>')}),getReadme:()=>z}}},H=require("path"),I=require("fs"),W=require("child_process"),G=e=>n=>`[${e}m${n}[0m`,Q=G(92),X=G(91),K=(e,n="...")=>{process.stdout.write(`- ${e}${n}`);const t=n=>()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(n?Q(`+ ${e}`):X(`* ${e}`)),process.stdout.write("\n")};return{resolve:t(!0),reject:t(!1)}},[,,V,Y]=process.argv;(()=>{if(!V||!Y)return void console.log("Expected name of layer and name");const e=B[V];if(!e)return void console.log(`Unknown layer: ${V}`);const n=K("file copying");((e,n)=>{const{scaffold:t,getSrc:r}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...y(e)},e.scaffold["README.md"]=`# ${n}\n\n${e.getReadme()}`})(e,n);const s={...t,...Object.entries(r()).reduce(((e,[n,t])=>(e[`src/${n}`]=t,e)),{})};Object.entries(s).forEach((([e,t])=>{const r=(0,H.resolve)(n,e),s="string"==typeof t?t:JSON.stringify(t,null,2);(0,I.mkdirSync)((0,H.dirname)(r),{recursive:!0}),(0,I.writeFileSync)(r,s)}))})(e(),Y),n.resolve(),(async(e,n)=>{const t=(0,H.resolve)(n),r=e=>new Promise((n=>{(0,W.exec)(e,{cwd:t},n)})),s=K("node_modules installing"," (this can take much time)");await r("npm i"),s.resolve();const o=K("raw text formatting");await r("npm run lint"),await r("npm run format-json"),o.resolve();const i=K("making the first commit");await r("git init"),await r("git add ."),await r(`git commit -m "${e} created"`),i.resolve()})(V,Y).then((()=>{console.log(""),console.log("done.")}))})()},856:e=>{e.exports="import { writeFileSync } from 'fs'\n\nimport { distPackageJson } from './dependencies'\n\nwriteFileSync('dist/package.json', distPackageJson)\n"},110:e=>{e.exports="import packageJson from '../package.json'\n\nconst { dependencies: deps } = packageJson as {\n dependencies?: Record<string, string>\n}\n\nexport const dependencies = deps || {}\n\nexport const externals = Object.keys(dependencies).reduce((acc, cur) => {\n acc[cur] = `commonjs ${cur}`\n\n return acc\n}, {} as Record<string, string>)\n\nexport const distPackageJson = JSON.stringify({ dependencies })\n"},510:e=>{e.exports="import { resolve } from 'path'\n\nimport { alias } from './dev-helpers/alias'\nimport { externals } from './dev-helpers/dependencies'\n\nexport default {\n target: 'node',\n mode: 'production',\n entry: resolve('src/main.ts'),\n output: {\n path: resolve('dist'),\n filename: 'bin.js',\n },\n resolve: {\n alias,\n extensions: ['.js', '.ts'],\n },\n externals,\n module: {\n rules: [\n {\n test: /\\.ts$/,\n exclude: /node_modules/,\n loader: 'babel-loader',\n options: {\n babelrc: false,\n presets: ['@babel/preset-typescript'],\n },\n },\n ],\n },\n}\n"},906:e=>{e.exports="Readme of 'backend'\n"},551:e=>{e.exports="import { app } from '@/app'\n\ndescribe('app', () => {\n it('should be defined', () => {\n expect(app).toBeDefined()\n })\n})\n"},130:e=>{e.exports="import { RequestListener } from 'http'\n\nexport const app: RequestListener = (_, res) => {\n res.write('It works!')\n res.end()\n}\n"},233:e=>{e.exports="import { createServer } from 'http'\n\nimport { app } from '@/app'\n\nconst port = 8088\n\ncreateServer(app).listen(port)\n\nconsole.log(`server is listening ${port} port`)\n"},127:e=>{e.exports="import { join, resolve } from 'path'\n\nimport tsconfig from '../tsconfig.json'\n\nconst { baseUrl, paths } = tsconfig.compilerOptions\n\nexport const alias = Object.entries(paths).reduce((acc, [key, [value]]) => {\n const [symbol] = key.split('/*')\n const [path] = value.split('/*')\n\n acc[symbol] = resolve(join(baseUrl, path))\n\n return acc\n}, {} as Record<string, string>)\n"},296:e=>{e.exports=".vscode\n.idea\n\nnode_modules\ndist\n\npackage-lock.json\n"},504:e=>{e.exports="import { alias } from './dev-helpers/alias'\n\nexport default {\n verbose: true,\n moduleNameMapper: Object.entries(alias).reduce((acc, [key, value]) => {\n acc[key + '/(.*)'] = value + '/$1'\n\n return acc\n }, {} as Record<string, string>),\n}\n"},431:e=>{e.exports='<?xml version="1.0" encoding="UTF-8"?>\n<project version="4">\n <component name="EslintConfiguration">\n <option name="fix-on-save" value="true" />\n </component>\n</project>\n'},834:e=>{e.exports='<component name="InspectionProjectProfileManager">\n <profile version="1.0">\n <option name="myName" value="Project Default" />\n <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />\n </profile>\n</component>\n'},217:e=>{e.exports='{\n "editor.codeActionsOnSave": { "source.fixAll.eslint": true }\n}\n'},604:e=>{e.exports='<?xml version="1.0" encoding="UTF-8"?>\n<project version="4">\n <component name="ProjectTasksOptions" suppressed-tasks="SCSS" />\n</project>\n'},836:e=>{e.exports="Readme of 'code'\n"},630:e=>{e.exports="import { arraySum } from '@/array-sum'\n\ndescribe('array-sum', () => {\n it('should be defined', () => {\n expect(arraySum).toBeDefined()\n })\n\n it('should count correctly', () => {\n expect(arraySum([1, 2, 3])).toBe(6)\n })\n})\n"},362:e=>{e.exports="export const arraySum = (arr: number[]): number =>\n arr.reduce((acc, cur) => acc + cur)\n"},901:e=>{e.exports="declare module '*.jpg' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.png' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.webp' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.svg' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n"},285:e=>{e.exports="import { resolve } from 'path'\n\nimport HtmlPlugin from 'html-webpack-plugin'\nimport CopyPlugin from 'copy-webpack-plugin'\nimport MiniCssPlugin from 'mini-css-extract-plugin'\n\nimport { alias } from './dev-helpers/alias'\nimport { devRoot, devPlugins } from './dev-helpers/webpack-dev'\nimport { prodRoot, prodPlugins } from './dev-helpers/webpack-prod'\n\nconst isDev = process.argv[2] == 'serve'\n\nexport default {\n ...(isDev ? devRoot : prodRoot),\n\n entry: resolve('src/main.ts'),\n resolve: {\n alias,\n extensions: ['.js', '.ts'],\n },\n module: {\n rules: [\n {\n test: /\\.ts$/,\n exclude: /node_modules/,\n loader: 'babel-loader',\n options: {\n babelrc: false,\n presets: ['@babel/preset-typescript'],\n },\n },\n {\n test: /\\.s[ac]ss$/,\n use: [\n (isDev ? 'style-loader' : MiniCssPlugin.loader),\n 'css-loader',\n 'sass-loader',\n ],\n },\n {\n test: /\\.(woff2|jpg|png|webp|svg)/,\n type: 'asset',\n },\n ],\n },\n plugins: [\n ...(isDev ? devPlugins : prodPlugins),\n\n new HtmlPlugin({ template: resolve('src/index.html') }),\n new CopyPlugin({\n patterns: [\n {\n from: resolve('src/favicon.svg'),\n to: resolve('dist'),\n },\n ],\n }),\n ],\n}\n"},872:e=>{e.exports="import { HotModuleReplacementPlugin } from 'webpack'\n\nexport const devRoot = {\n mode: 'development',\n output: {\n publicPath: '/',\n },\n devServer: {\n hot: true,\n port: 5445,\n historyApiFallback: true,\n },\n devtool: 'inline-source-map',\n}\n\nexport const devPlugins = [new HotModuleReplacementPlugin]\n"},642:e=>{e.exports="import { resolve } from 'path'\n\nimport { CleanWebpackPlugin } from 'clean-webpack-plugin'\nimport MiniCssPlugin from 'mini-css-extract-plugin'\n\nexport const prodRoot = {\n mode: 'production',\n output: {\n filename: 'bundle.[contenthash].js',\n path: resolve('dist'),\n },\n}\n\nexport const prodPlugins = [\n new CleanWebpackPlugin,\n new MiniCssPlugin({ filename: '[contenthash].css' }),\n]\n"},247:e=>{e.exports="Readme of 'frontend'\n"},986:e=>{e.exports='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0"\n\t viewBox="0 0 512 512" style="enable-background:new 0 0 512 512" xml:space="preserve">\n<path fill="#0078CF" d="M512,256c0,23.155-3.072,45.599-8.84,66.936c-13.479,49.894-41.66,93.748-79.621,126.631\n\tC378.64,488.469,320.073,512,256,512C114.615,512,0,397.385,0,256S114.615,0,256,0S512,114.615,512,256z"/>\n<g>\n\t<path fill="#F2F2F2" d="M503.16,322.936c-13.479,49.894-41.66,93.748-79.621,126.631c-3.709,0.199-7.586,0.293-11.609,0.293\n\t\tc-53.154,0-82.693-33.217-97.374-58.138l48.191-28.954c0,0,16.394,34.837,47.125,34.837c30.741,0,43.039-10.25,43.039-33.813\n\t\tc0-28.693-99.391-38.933-114.761-88.116c-15.37-49.183,5.12-118.868,76.852-113.737c44.826,3.197,70.04,25.213,82.651,41.273\n\t\tl-47.815,34.544c-10.25-29.706-52.255-29.706-60.458-5.12c-8.192,24.597,19.466,38.933,62.506,53.279\n\t\tC473.997,293.282,491.781,306.876,503.16,322.936z"/>\n\t<polygon fill="#F2F2F2" points="300.943,169.786 83.106,169.786 83.106,221.202 162.935,221.202 162.935,444.45\n\t\t221.115,444.45 221.115,221.202 300.943,221.202"/>\n</g>\n</svg>\n'},556:e=>{e.exports='<div class="demo-app">\n <h1>Ваше frontend-приложение</h1>\n <p>Подробнее на\n <a\n href="https://github.com/nelkor/create-layer"\n target="_blank"\n rel="noopener noreferrer"\n >github</a>\n </p>\n</div>\n'},402:e=>{e.exports="html {\n font-family: sans-serif;\n color: #333;\n}\n\nbody {\n padding: 0;\n margin: 0;\n width: 100vw;\n height: 100vh;\n}\n\n.demo-app {\n width: 100%;\n height: calc(100% - 100px);\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n text-align: center;\n\n h1 {\n font-size: 26px;\n }\n\n p {\n font-size: 20px;\n margin: 0;\n }\n}\n"},191:e=>{e.exports="import '@/main.scss'\n"},532:e=>{e.exports="Readme of 'react'\n"},450:e=>{e.exports='import React, { FC } from \'react\'\nimport { render } from \'react-dom\'\n\nconst App: FC = () => (\n <>\n <h1>Ваше react-приложение</h1>\n <p>\n Подробнее на\n <a\n href="https://github.com/nelkor/create-layer"\n target="_blank"\n rel="noopener noreferrer"\n >\n github\n </a>\n </p>\n </>\n)\n\nexport const renderApp = (root: Element | null): void => render(<App />, root)\n'},235:e=>{e.exports="import './main.scss'\n\nimport { renderApp } from './App'\n\nrenderApp(document.querySelector('#react-root'))\n"},887:e=>{e.exports='<!doctype html>\n<html lang="ru">\n<head>\n <meta charset="UTF-8">\n <meta\n name="viewport"\n content="width=device-width,\n user-scalable=no,\n initial-scale=1.0,\n maximum-scale=1.0,\n minimum-scale=1.0"\n >\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <title>{{ title }}</title>\n <link rel="icon" href="/favicon.svg">\n</head>\n<body>\n\n{{ body }}\n\n</body>\n</html>\n'}},n={};!function t(r){var s=n[r];if(void 0!==s)return s.exports;var o=n[r]={exports:{}};return e[r](o,o.exports,t),o.exports}(474)})(); | ||
(()=>{"use strict";var e={474:(e,n,t)=>{var r=t(834),s=t(431),o=t(604),i=t(217),a=t(127);const p=JSON.parse('{"presets":["@babel/preset-env","@babel/preset-typescript"]}'),l=JSON.parse('{"env":{"node":true,"es6":true},"settings":{"import/resolver":{"typescript":{}}},"parser":"@typescript-eslint/parser","parserOptions":{"project":"tsconfig.json","tsconfigRootDir":"."},"plugins":["prettier","import","@typescript-eslint"],"extends":["prettier","eslint:recommended","plugin:prettier/recommended","plugin:import/errors","plugin:@typescript-eslint/recommended"],"rules":{"prettier/prettier":2,"import/first":2,"import/newline-after-import":2,"import/order":[2,{"pathGroups":[{"pattern":"@*/**","group":"parent"},{"pattern":".*/**","group":"sibling"}],"newlines-between":"always"}],"no-else-return":2,"no-return-await":2,"camelcase":2,"no-return-assign":2,"prefer-destructuring":[2,{"object":true,"array":false}],"curly":[2,"all"],"no-unused-expressions":2,"object-shorthand":[2,"always",{"avoidQuotes":true,"avoidExplicitReturnArrows":true}],"no-await-in-loop":2,"no-loss-of-precision":2,"no-promise-executor-return":2,"no-useless-backreference":2,"array-callback-return":2,"consistent-return":2,"dot-notation":2,"no-extend-native":2,"no-lone-blocks":2,"no-multi-str":2,"no-proto":2,"require-await":2,"prefer-template":2,"prefer-arrow-callback":2,"arrow-body-style":2,"max-len":[2,{"code":80}],"padding-line-between-statements":["error",{"blankLine":"always","prev":"*","next":"return"},{"blankLine":"always","prev":"*","next":["multiline-block-like","multiline-const","multiline-let"]},{"blankLine":"always","prev":["multiline-block-like","multiline-const","multiline-let"],"next":"*"},{"blankLine":"always","prev":"singleline-const","next":"*"},{"blankLine":"always","prev":"singleline-let","next":"*"},{"blankLine":"always","prev":"*","next":"singleline-const"},{"blankLine":"always","prev":"*","next":"singleline-let"},{"blankLine":"any","prev":"singleline-let","next":"singleline-let"},{"blankLine":"any","prev":"singleline-const","next":"singleline-const"}]}}'),c=JSON.parse('{"semi":false,"singleQuote":true,"arrowParens":"avoid","quoteProps":"consistent"}');var d=t(296),m=t(504);const u=JSON.parse('{"private":true,"scripts":{"test":"jest","ts":"tsc --noemit","lint":"eslint . --ext .ts --fix","format-json":"prettier **/*.json .*rc --write"},"devDependencies":{"@babel/core":"^7.13.15","@babel/preset-env":"^7.13.15","@babel/preset-typescript":"^7.13.0","@types/jest":"^26.0.22","@typescript-eslint/eslint-plugin":"^4.22.0","@typescript-eslint/parser":"^4.22.0","babel-jest":"^26.6.3","eslint":"^7.24.0","eslint-config-prettier":"^8.2.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.4.0","jest":"^26.6.3","prettier":"^2.2.1","ts-node":"^9.1.1","typescript":"^4.2.4"}}'),g=JSON.parse('{"compilerOptions":{"strict":true,"target":"esnext","lib":["esnext"],"moduleResolution":"node","esModuleInterop":true,"resolveJsonModule":true,"skipLibCheck":true,"typeRoots":["node_modules/@types","index.d.ts"],"baseUrl":"src","paths":{"@/*":["./*"]}}}');var f=t(362),v=t(630),b=t(836);const x=()=>({scaffold:{".idea/inspectionProfiles/Project_Default.xml":r,".idea/jsLinters/eslint.xml":s,".idea/watcherTasks.xml":o,".vscode/settings.json":i,"dev-helpers/alias.ts":a,".babelrc":p,".eslintrc":l,".prettierrc":c,".gitignore":d,"index.d.ts":"","jest.config.ts":m,"package.json":u,"tsconfig.json":g},getSrc:()=>({"array-sum.ts":f,"array-sum.spec.ts":v}),getReadme:()=>b}),y=e=>e.scaffold["package.json"],h=e=>e.scaffold["tsconfig.json"].compilerOptions;var w=t(110),k=t(856),j=t(510),P=t(233),R=t(130),S=t(551),$=t(906),C=t(887);const O=(e,n)=>C.replace("{{ title }}",e).replace("{{ body }}",n);var D=t(901),F=t(872),A=t(642),L=t(285),J=t(986),M=t(556),_=t(402),N=t(191),q=t(247);const E=()=>{const e=x(),n=h(e),t=y(e),{scripts:r,devDependencies:s}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]=D,r["format-scss"]="prettier **/*.scss --write",r.build="webpack",r.serve="webpack serve",t.devDependencies={...s,webpack:"^5.28.0","webpack-cli":"^4.6.0","webpack-dev-server":"^3.11.2","babel-loader":"^8.2.2","css-loader":"^5.2.0","sass-loader":"^11.0.1","style-loader":"^2.0.0","mini-css-extract-plugin":"^1.4.0",sass:"^1.32.8","html-webpack-plugin":"^5.3.1","clean-webpack-plugin":"^3.0.0","copy-webpack-plugin":"^8.1.0","@types/mini-css-extract-plugin":"^1.4.1","@types/copy-webpack-plugin":"^6.4.1"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":F,"dev-helpers/webpack-prod.ts":A,"webpack.config.ts":L},getSrc:()=>({"favicon.svg":J,"index.html":O("Frontend",M),"main.scss":_,"main.ts":N,"array-sum.ts":f,"array-sum.spec.ts":v}),getReadme:()=>q}};var U=t(450),T=t(235),z=t(532);const B={code:x,backend:()=>{const e=x(),n=y(e),{scripts:t,devDependencies:r}=n;return t.build="webpack && ts-node dev-helpers/create-package.ts",t.start="node dist",n.devDependencies={...r,"@types/node":"^14.14.39",webpack:"^5.28.0","webpack-cli":"^4.6.0","babel-loader":"^8.2.2"},{scaffold:{...e.scaffold,"dev-helpers/dependencies.ts":w,"dev-helpers/create-package.ts":k,"webpack.config.ts":j},getSrc:()=>({"main.ts":P,"app.ts":R,"app.spec.ts":S}),getReadme:()=>$}},frontend:E,react:()=>{const e=E(),n=h(e),t="webpack.config.ts",r="'@babel/preset-typescript'",s=`'@babel/preset-react', ${r}`,o=e.scaffold[t];return(e=>{const n=e.scaffold[".babelrc"],t=n.presets.pop();n.presets.push("@babel/preset-react"),n.presets.push(t)})(e),(e=>{const n=y(e),{devDependencies:t,scripts:r}=n;r.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@types/react":"^17.0.3","@types/react-dom":"^17.0.3","@babel/preset-react":"^7.13.13","eslint-plugin-react":"^7.23.1"},n.dependencies={react:"^17.0.2","react-dom":"^17.0.2"}})(e),(e=>{const n=(e=>e.scaffold[".eslintrc"])(e);n.extends.push("plugin:react/recommended"),n.settings.react={version:"detect"},n.rules={...n.rules,"react/jsx-uses-vars":2,"react/jsx-boolean-value":2,"react/self-closing-comp":2,"react/jsx-fragments":2}})(e),e.scaffold[t]=o.replace("'.ts'","'.ts', '.tsx'").replace(".ts$",".tsx?$").replace(r,s),n.jsx="react",{scaffold:e.scaffold,getSrc:()=>({"App.tsx":U,"main.ts":T,"main.scss":_,"favicon.svg":J,"index.html":O("React",'<div id="react-root"></div>')}),getReadme:()=>z}}},H=require("path"),I=require("fs"),W=require("child_process"),G=e=>n=>`[${e}m${n}[0m`,Q=G(92),X=G(91),K=(e,n="...")=>{process.stdout.write(`- ${e}${n}`);const t=n=>()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(n?Q(`+ ${e}`):X(`* ${e}`)),process.stdout.write("\n")};return{resolve:t(!0),reject:t(!1)}},[,,V,Y]=process.argv;(()=>{if(!V||!Y)return void console.log("Expected name of layer and name");const e=B[V];if(!e)return void console.log(`Unknown layer: ${V}`);const n=K("file copying");((e,n)=>{const{scaffold:t,getSrc:r}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...y(e)},e.scaffold["README.md"]=`# ${n}\n\n${e.getReadme()}`})(e,n);const s={...t,...Object.entries(r()).reduce(((e,[n,t])=>(e[`src/${n}`]=t,e)),{})};Object.entries(s).forEach((([e,t])=>{const r=(0,H.resolve)(n,e),s="string"==typeof t?t:JSON.stringify(t,null,2);(0,I.mkdirSync)((0,H.dirname)(r),{recursive:!0}),(0,I.writeFileSync)(r,s)}))})(e(),Y),n.resolve(),(async(e,n)=>{const t=(0,H.resolve)(n),r=e=>new Promise((n=>{(0,W.exec)(e,{cwd:t},n)})),s=K("node_modules installing"," (this can take much time)");await r("npm i"),s.resolve();const o=K("raw text formatting");await r("npm run lint"),await r("npm run format-json"),o.resolve();const i=K("making the first commit");await r("git init"),await r("git add ."),await r(`git commit -m "${e} created"`),i.resolve()})(V,Y).then((()=>{console.log(""),console.log("done.")}))})()},856:e=>{e.exports="import { writeFileSync } from 'fs'\n\nimport { distPackageJson } from './dependencies'\n\nwriteFileSync('dist/package.json', distPackageJson)\n"},110:e=>{e.exports="import packageJson from '../package.json'\n\nconst { dependencies: deps } = packageJson as {\n dependencies?: Record<string, string>\n}\n\nexport const dependencies = deps || {}\n\nexport const externals = Object.keys(dependencies).reduce((acc, cur) => {\n acc[cur] = `commonjs ${cur}`\n\n return acc\n}, {} as Record<string, string>)\n\nexport const distPackageJson = JSON.stringify({ dependencies })\n"},510:e=>{e.exports="import { resolve } from 'path'\n\nimport { alias } from './dev-helpers/alias'\nimport { externals } from './dev-helpers/dependencies'\n\nexport default {\n target: 'node',\n mode: 'production',\n entry: resolve('src/main.ts'),\n output: {\n path: resolve('dist'),\n filename: 'index.js',\n },\n resolve: {\n alias,\n extensions: ['.js', '.ts'],\n },\n externals,\n module: {\n rules: [\n {\n test: /\\.ts$/,\n exclude: /node_modules/,\n loader: 'babel-loader',\n options: {\n babelrc: false,\n presets: ['@babel/preset-typescript'],\n },\n },\n ],\n },\n}\n"},906:e=>{e.exports="Readme of 'backend'\n"},551:e=>{e.exports="import { app } from '@/app'\n\ndescribe('app', () => {\n it('should be defined', () => {\n expect(app).toBeDefined()\n })\n})\n"},130:e=>{e.exports="import { RequestListener } from 'http'\n\nexport const app: RequestListener = (_, res) => {\n res.write('It works!')\n res.end()\n}\n"},233:e=>{e.exports="import { createServer } from 'http'\n\nimport { app } from '@/app'\n\nconst port = 8088\n\ncreateServer(app).listen(port)\n\nconsole.log(`server is listening ${port} port`)\n"},127:e=>{e.exports="import { join, resolve } from 'path'\n\nimport tsconfig from '../tsconfig.json'\n\nconst { baseUrl, paths } = tsconfig.compilerOptions\n\nexport const alias = Object.entries(paths).reduce((acc, [key, [value]]) => {\n const [symbol] = key.split('/*')\n const [path] = value.split('/*')\n\n acc[symbol] = resolve(join(baseUrl, path))\n\n return acc\n}, {} as Record<string, string>)\n"},296:e=>{e.exports=".vscode\n.idea\n\nnode_modules\ndist\n\npackage-lock.json\n"},504:e=>{e.exports="import { alias } from './dev-helpers/alias'\n\nexport default {\n verbose: true,\n moduleNameMapper: Object.entries(alias).reduce((acc, [key, value]) => {\n acc[key + '/(.*)'] = value + '/$1'\n\n return acc\n }, {} as Record<string, string>),\n}\n"},431:e=>{e.exports='<?xml version="1.0" encoding="UTF-8"?>\n<project version="4">\n <component name="EslintConfiguration">\n <option name="fix-on-save" value="true" />\n </component>\n</project>\n'},834:e=>{e.exports='<component name="InspectionProjectProfileManager">\n <profile version="1.0">\n <option name="myName" value="Project Default" />\n <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />\n </profile>\n</component>\n'},217:e=>{e.exports='{\n "editor.codeActionsOnSave": { "source.fixAll.eslint": true }\n}\n'},604:e=>{e.exports='<?xml version="1.0" encoding="UTF-8"?>\n<project version="4">\n <component name="ProjectTasksOptions" suppressed-tasks="SCSS" />\n</project>\n'},836:e=>{e.exports="Readme of 'code'\n"},630:e=>{e.exports="import { arraySum } from '@/array-sum'\n\ndescribe('array-sum', () => {\n it('should be defined', () => {\n expect(arraySum).toBeDefined()\n })\n\n it('should count correctly', () => {\n expect(arraySum([1, 2, 3])).toBe(6)\n })\n})\n"},362:e=>{e.exports="export const arraySum = (arr: number[]): number =>\n arr.reduce((acc, cur) => acc + cur)\n"},901:e=>{e.exports="declare module '*.jpg' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.png' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.webp' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n\r\ndeclare module '*.svg' {\r\n const text: string\r\n\r\n export default text\r\n}\r\n"},285:e=>{e.exports="import { resolve } from 'path'\n\nimport HtmlPlugin from 'html-webpack-plugin'\nimport CopyPlugin from 'copy-webpack-plugin'\nimport MiniCssPlugin from 'mini-css-extract-plugin'\n\nimport { alias } from './dev-helpers/alias'\nimport { devRoot, devPlugins } from './dev-helpers/webpack-dev'\nimport { prodRoot, prodPlugins } from './dev-helpers/webpack-prod'\n\nconst isDev = process.argv[2] == 'serve'\n\nexport default {\n ...(isDev ? devRoot : prodRoot),\n\n entry: resolve('src/main.ts'),\n resolve: {\n alias,\n extensions: ['.js', '.ts'],\n },\n module: {\n rules: [\n {\n test: /\\.ts$/,\n exclude: /node_modules/,\n loader: 'babel-loader',\n options: {\n babelrc: false,\n presets: ['@babel/preset-typescript'],\n },\n },\n {\n test: /\\.s[ac]ss$/,\n use: [\n (isDev ? 'style-loader' : MiniCssPlugin.loader),\n 'css-loader',\n 'sass-loader',\n ],\n },\n {\n test: /\\.(woff2|jpg|png|webp|svg)/,\n type: 'asset',\n },\n ],\n },\n plugins: [\n ...(isDev ? devPlugins : prodPlugins),\n\n new HtmlPlugin({ template: resolve('src/index.html') }),\n new CopyPlugin({\n patterns: [\n {\n from: resolve('src/favicon.svg'),\n to: resolve('dist'),\n },\n ],\n }),\n ],\n}\n"},872:e=>{e.exports="import { HotModuleReplacementPlugin } from 'webpack'\n\nexport const devRoot = {\n mode: 'development',\n output: {\n publicPath: '/',\n },\n devServer: {\n hot: true,\n port: 5445,\n historyApiFallback: true,\n },\n devtool: 'inline-source-map',\n}\n\nexport const devPlugins = [new HotModuleReplacementPlugin]\n"},642:e=>{e.exports="import { resolve } from 'path'\n\nimport { CleanWebpackPlugin } from 'clean-webpack-plugin'\nimport MiniCssPlugin from 'mini-css-extract-plugin'\n\nexport const prodRoot = {\n mode: 'production',\n output: {\n publicPath: '/',\n filename: 'bundle.[contenthash].js',\n path: resolve('dist'),\n },\n}\n\nexport const prodPlugins = [\n new CleanWebpackPlugin,\n new MiniCssPlugin({ filename: '[contenthash].css' }),\n]\n"},247:e=>{e.exports="Readme of 'frontend'\n"},986:e=>{e.exports='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0"\n\t viewBox="0 0 512 512" style="enable-background:new 0 0 512 512" xml:space="preserve">\n<path fill="#0078CF" d="M512,256c0,23.155-3.072,45.599-8.84,66.936c-13.479,49.894-41.66,93.748-79.621,126.631\n\tC378.64,488.469,320.073,512,256,512C114.615,512,0,397.385,0,256S114.615,0,256,0S512,114.615,512,256z"/>\n<g>\n\t<path fill="#F2F2F2" d="M503.16,322.936c-13.479,49.894-41.66,93.748-79.621,126.631c-3.709,0.199-7.586,0.293-11.609,0.293\n\t\tc-53.154,0-82.693-33.217-97.374-58.138l48.191-28.954c0,0,16.394,34.837,47.125,34.837c30.741,0,43.039-10.25,43.039-33.813\n\t\tc0-28.693-99.391-38.933-114.761-88.116c-15.37-49.183,5.12-118.868,76.852-113.737c44.826,3.197,70.04,25.213,82.651,41.273\n\t\tl-47.815,34.544c-10.25-29.706-52.255-29.706-60.458-5.12c-8.192,24.597,19.466,38.933,62.506,53.279\n\t\tC473.997,293.282,491.781,306.876,503.16,322.936z"/>\n\t<polygon fill="#F2F2F2" points="300.943,169.786 83.106,169.786 83.106,221.202 162.935,221.202 162.935,444.45\n\t\t221.115,444.45 221.115,221.202 300.943,221.202"/>\n</g>\n</svg>\n'},556:e=>{e.exports='<div class="demo-app">\n <h1>Ваше frontend-приложение</h1>\n <p>Подробнее на\n <a\n href="https://github.com/nelkor/create-layer"\n target="_blank"\n rel="noopener noreferrer"\n >github</a>\n </p>\n</div>\n'},402:e=>{e.exports="html {\n font-family: sans-serif;\n color: #333;\n}\n\nbody {\n padding: 0;\n margin: 0;\n width: 100vw;\n height: 100vh;\n}\n\n.demo-app {\n width: 100%;\n height: calc(100% - 100px);\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n text-align: center;\n\n h1 {\n font-size: 26px;\n }\n\n p {\n font-size: 20px;\n margin: 0;\n }\n}\n"},191:e=>{e.exports="import '@/main.scss'\n"},532:e=>{e.exports="Readme of 'react'\n"},450:e=>{e.exports='import React, { FC } from \'react\'\nimport { render } from \'react-dom\'\n\nconst App: FC = () => (\n <>\n <h1>Ваше react-приложение</h1>\n <p>\n Подробнее на\n <a\n href="https://github.com/nelkor/create-layer"\n target="_blank"\n rel="noopener noreferrer"\n >\n github\n </a>\n </p>\n </>\n)\n\nexport const renderApp = (root: Element | null): void => render(<App />, root)\n'},235:e=>{e.exports="import './main.scss'\n\nimport { renderApp } from './App'\n\nrenderApp(document.querySelector('#react-root'))\n"},887:e=>{e.exports='<!doctype html>\n<html lang="ru">\n<head>\n <meta charset="UTF-8">\n <meta\n name="viewport"\n content="width=device-width,\n user-scalable=no,\n initial-scale=1.0,\n maximum-scale=1.0,\n minimum-scale=1.0"\n >\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <title>{{ title }}</title>\n <link rel="icon" href="/favicon.svg">\n</head>\n<body>\n\n{{ body }}\n\n</body>\n</html>\n'}},n={};!function t(r){var s=n[r];if(void 0!==s)return s.exports;var o=n[r]={exports:{}};return e[r](o,o.exports,t),o.exports}(474)})(); |
{ | ||
"name": "create-layer", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "generator of starters", | ||
@@ -5,0 +5,0 @@ "preferGlobal": true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17846
3
1
2