create-layer
Advanced tools
Comparing version 1.0.8 to 1.0.9
#!/usr/bin/env node | ||
(()=>{"use strict";var e={474:(e,n,t)=>{var s=t(834),r=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.14.6","@babel/preset-env":"^7.14.5","@babel/preset-typescript":"^7.14.5","@types/jest":"^26.0.23","@typescript-eslint/eslint-plugin":"^4.27.0","@typescript-eslint/parser":"^4.27.0","babel-jest":"^27.0.2","eslint":"^7.29.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.23.4","eslint-plugin-prettier":"^3.4.0","jest":"^27.0.4","prettier":"^2.3.1","ts-node":"^10.0.0","typescript":"^4.3.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":s,".idea/jsLinters/eslint.xml":r,".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 F=(e,n)=>C.replace("{{ title }}",e).replace("{{ body }}",n);var O=t(901),D=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:s,devDependencies:r}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]=O,s["format-scss"]="prettier **/*.scss --write",s.build="webpack",s.serve="webpack serve",t.devDependencies={...r,"@types/copy-webpack-plugin":"^8.0.0","@types/mini-css-extract-plugin":"^1.4.3","babel-loader":"^8.2.2","clean-webpack-plugin":"^4.0.0-alpha.0","copy-webpack-plugin":"^9.0.0","css-loader":"^5.2.6","html-webpack-plugin":"^5.3.1","mini-css-extract-plugin":"^1.6.0",sass:"^1.35.1","sass-loader":"^12.1.0","style-loader":"^2.0.0",webpack:"^5.39.1","webpack-cli":"^4.7.2","webpack-dev-server":"^3.11.2"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":D,"dev-helpers/webpack-prod.ts":A,"webpack.config.ts":L},getSrc:()=>({"favicon.svg":J,"index.html":F("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),B=t(532);const H={code:b,backend:()=>{const e=b(),n=y(e),{scripts:t,devDependencies:s}=n;return t.build="webpack && ts-node dev-helpers/create-package.ts",t.start="node dist",n.devDependencies={...s,"@types/node":"^15.12.4","babel-loader":"^8.2.2",webpack:"^5.39.1","webpack-cli":"^4.7.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",s="'@babel/preset-typescript'",r=`'@babel/preset-react', ${s}`,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:s}=n;s.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@babel/preset-react":"^7.14.5","@types/react":"^17.0.11","@types/react-dom":"^17.0.8","eslint-plugin-react":"^7.24.0"},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(s,r),n.jsx="react",{scaffold:e.scaffold,getSrc:()=>({"App.tsx":U,"main.ts":T,"main.scss":_,"favicon.svg":J,"index.html":F("React",'<div class="demo-app"></div>')}),getReadme:()=>B}}},I=require("path"),z=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=H[V];if(!e)return void console.log(`Unknown layer: ${V}`);const n=K("file copying");((e,n)=>{const{scaffold:t,getSrc:s}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...y(e)},e.scaffold["README.md"]=`# ${n}\n\n${e.getReadme()}`})(e,n);const r={...t,...Object.entries(s()).reduce(((e,[n,t])=>(e[`src/${n}`]=t,e)),{})};Object.entries(r).forEach((([e,t])=>{const s=(0,I.resolve)(n,e),r="string"==typeof t?t:JSON.stringify(t,null,2);(0,z.mkdirSync)((0,I.dirname)(s),{recursive:!0}),(0,z.writeFileSync)(s,r)}))})(e(),Y),n.resolve(),(async(e,n)=>{const t=(0,I.resolve)(n),s=e=>new Promise((n=>{(0,W.exec)(e,{cwd:t},n)})),r=K("node_modules installing"," (this can take much time)");await s("npm i"),r.resolve();const o=K("raw text formatting");await s("npm run lint"),await s("npm run format-json"),o.resolve();const i=K("making the first commit");await s("git init"),await s("git add ."),await s(`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' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.png' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.webp' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.svg' {\n const text: string\n\n export default text\n}\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 starter-app</h1>\n <a\n href="https://github.com/nelkor/create-layer/tree/main/src/layers/frontend"\n target="_blank"\n rel="noopener noreferrer"\n >\n readme is here\n </a>\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"},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 starter-app</h1>\n <a\n href="https://github.com/nelkor/create-layer/tree/main/src/layers/react"\n target="_blank"\n rel="noopener noreferrer"\n >\n readme is here\n </a>\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('.demo-app'))\n"},887:e=>{e.exports='<!doctype html>\n<html lang="">\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</body>\n</html>\n'}},n={};!function t(s){var r=n[s];if(void 0!==r)return r.exports;var o=n[s]={exports:{}};return e[s](o,o.exports,t),o.exports}(474)})(); | ||
(()=>{"use strict";var e={474:(e,n,t)=>{var s=t(834),r=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.14.6","@babel/preset-env":"^7.14.7","@babel/preset-typescript":"^7.14.5","@types/jest":"^26.0.24","@typescript-eslint/eslint-plugin":"^4.28.2","@typescript-eslint/parser":"^4.28.2","babel-jest":"^27.0.6","eslint":"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.4.0","eslint-plugin-import":"^2.23.4","eslint-plugin-prettier":"^3.4.0","jest":"^27.0.6","prettier":"^2.3.2","ts-node":"^10.0.0","typescript":"^4.3.5"}}'),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":s,".idea/jsLinters/eslint.xml":r,".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 F=(e,n)=>C.replace("{{ title }}",e).replace("{{ body }}",n);var O=t(901),D=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:s,devDependencies:r}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]=O,s["format-scss"]="prettier **/*.scss --write",s.build="webpack",s.serve="webpack serve",t.devDependencies={...r,"@types/copy-webpack-plugin":"^8.0.1","@types/mini-css-extract-plugin":"^2.0.1","babel-loader":"^8.2.2","clean-webpack-plugin":"^4.0.0-alpha.0","copy-webpack-plugin":"^9.0.1","css-loader":"^5.2.6","html-webpack-plugin":"^5.3.2","mini-css-extract-plugin":"^2.1.0",sass:"^1.35.2","sass-loader":"^12.1.0","style-loader":"^3.0.0",webpack:"^5.43.0","webpack-cli":"^4.7.2","webpack-dev-server":"^3.11.2"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":D,"dev-helpers/webpack-prod.ts":A,"webpack.config.ts":L},getSrc:()=>({"favicon.svg":J,"index.html":F("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),B=t(532);const H={code:b,backend:()=>{const e=b(),n=y(e),{scripts:t,devDependencies:s}=n;return t.build="webpack && ts-node dev-helpers/create-package.ts",t.start="node dist",n.devDependencies={...s,"@types/node":"^15.12.4","babel-loader":"^8.2.2",webpack:"^5.39.1","webpack-cli":"^4.7.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",s="'@babel/preset-typescript'",r=`'@babel/preset-react', ${s}`,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:s}=n;s.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@babel/preset-react":"^7.14.5","@types/react":"^17.0.11","@types/react-dom":"^17.0.8","eslint-plugin-react":"^7.24.0"},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(s,r),n.jsx="react",{scaffold:e.scaffold,getSrc:()=>({"App.tsx":U,"main.ts":T,"main.scss":_,"favicon.svg":J,"index.html":F("React",'<div class="demo-app"></div>')}),getReadme:()=>B}}},I=require("path"),z=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=H[V];if(!e)return void console.log(`Unknown layer: ${V}`);const n=K("file copying");((e,n)=>{const{scaffold:t,getSrc:s}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...y(e)},e.scaffold["README.md"]=`# ${n}\n\n${e.getReadme()}`})(e,n);const r={...t,...Object.entries(s()).reduce(((e,[n,t])=>(e[`src/${n}`]=t,e)),{})};Object.entries(r).forEach((([e,t])=>{const s=(0,I.resolve)(n,e),r="string"==typeof t?t:JSON.stringify(t,null,2);(0,z.mkdirSync)((0,I.dirname)(s),{recursive:!0}),(0,z.writeFileSync)(s,r)}))})(e(),Y),n.resolve(),(async(e,n)=>{const t=(0,I.resolve)(n),s=e=>new Promise((n=>{(0,W.exec)(e,{cwd:t},n)})),r=K("node_modules installing"," (this can take much time)");await s("npm i"),r.resolve();const o=K("raw text formatting");await s("npm run lint"),await s("npm run format-json"),o.resolve();const i=K("making the first commit");await s("git init"),await s("git add ."),await s(`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' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.png' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.webp' {\n const text: string\n\n export default text\n}\n\ndeclare module '*.svg' {\n const text: string\n\n export default text\n}\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 starter-app</h1>\n <a\n href="https://github.com/nelkor/create-layer/tree/main/src/layers/frontend"\n target="_blank"\n rel="noopener noreferrer"\n >\n readme is here\n </a>\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"},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 starter-app</h1>\n <a\n href="https://github.com/nelkor/create-layer/tree/main/src/layers/react"\n target="_blank"\n rel="noopener noreferrer"\n >\n readme is here\n </a>\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('.demo-app'))\n"},887:e=>{e.exports='<!doctype html>\n<html lang="">\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</body>\n</html>\n'}},n={};!function t(s){var r=n[s];if(void 0!==r)return r.exports;var o=n[s]={exports:{}};return e[s](o,o.exports,t),o.exports}(474)})(); |
{ | ||
"name": "create-layer", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
17685