Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-layer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-layer - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

2

bin.js
#!/usr/bin/env node
(()=>{"use strict";var e={474:(e,n,t)=>{var r=t(127);const s=JSON.parse('{"presets":["@babel/preset-env","@babel/preset-typescript"]}'),o=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,"no-throw-literal":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":"export","next":"*"},{"blankLine":"always","prev":"*","next":"export"},{"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"}]}}'),i=JSON.parse('{"semi":false,"singleQuote":true,"arrowParens":"avoid","quoteProps":"consistent"}');var a=t(296),p=t(504);const l=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.16.5","@babel/preset-env":"^7.16.5","@babel/preset-typescript":"^7.16.5","@types/jest":"^27.0.3","@typescript-eslint/eslint-plugin":"^5.8.0","@typescript-eslint/parser":"^5.8.0","babel-jest":"^27.4.5","eslint":"^8.5.0","eslint-config-prettier":"^8.3.0","eslint-import-resolver-typescript":"^2.5.0","eslint-plugin-import":"^2.25.3","eslint-plugin-prettier":"^4.0.0","jest":"^27.4.5","prettier":"^2.5.1","ts-node":"^10.4.0","typescript":"^4.5.4"}}'),c=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 d=t(362),m=t(630),u=t(836);const g=()=>({scaffold:{"dev-helpers/alias.ts":r,".babelrc":s,".eslintrc":o,".prettierrc":i,".gitignore":a,"index.d.ts":"","jest.config.ts":p,"package.json":l,"tsconfig.json":c},getSrc:()=>({"array-sum.ts":d,"array-sum.spec.ts":m}),getReadme:()=>u}),f=e=>e.scaffold["package.json"],v=e=>e.scaffold["tsconfig.json"].compilerOptions;var b=t(110),x=t(856),y=t(510),h=t(233),w=t(130),k=t(551),j=t(906),S=t(887);const R=(e,n)=>S.replace("{{ title }}",e).replace("{{ body }}",n);var F=t(901),$=t(872),C=t(642),O=t(285),L=t(986),P=t(556),J=t(402),D=t(191),N=t(247);const A=()=>{const e=g(),n=v(e),t=f(e),{scripts:r,devDependencies:s}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]=F,r["format-scss"]="prettier **/*.scss --write",r.build="webpack",r.serve="webpack serve",t.devDependencies={...s,"@types/copy-webpack-plugin":"^10.1.0","@types/mini-css-extract-plugin":"^2.4.0","babel-loader":"^8.2.3","copy-webpack-plugin":"^10.2.0","css-loader":"^6.5.1","html-webpack-plugin":"^5.5.0","mini-css-extract-plugin":"^2.4.5",sass:"^1.45.1","sass-loader":"^12.4.0","style-loader":"^3.3.1",webpack:"^5.65.0","webpack-cli":"^4.9.1","webpack-dev-server":"^4.6.0"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":$,"dev-helpers/webpack-prod.ts":C,"webpack.config.ts":O},getSrc:()=>({"favicon.svg":L,"index.html":R("Frontend",P),"main.scss":J,"main.ts":D,"array-sum.ts":d,"array-sum.spec.ts":m}),getReadme:()=>N}};var M=t(450),q=t(235),_=t(532);const B={code:g,backend:()=>{const e=g(),n=f(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":"^16.7.1","babel-loader":"^8.2.2",webpack:"^5.51.1","webpack-cli":"^4.8.0"},{scaffold:{...e.scaffold,"dev-helpers/dependencies.ts":b,"dev-helpers/create-package.ts":x,"webpack.config.ts":y},getSrc:()=>({"main.ts":h,"app.ts":w,"app.spec.ts":k}),getReadme:()=>j}},frontend:A,react:()=>{const e=A(),n=v(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=f(e),{devDependencies:t,scripts:r}=n;r.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@babel/preset-react":"^7.14.5","@types/react":"^17.0.19","@types/react-dom":"^17.0.9","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(r,s),n.jsx="react",{scaffold:e.scaffold,getSrc:()=>({"App.tsx":M,"main.ts":q,"main.scss":J,"favicon.svg":L,"index.html":R("React",'<div class="demo-app"></div>')}),getReadme:()=>_}}},E=require("path"),I=require("fs"),U=require("child_process"),z=e=>n=>`[${e}m${n}`,H=z(92),Q=z(91),T=(e,n="...")=>{process.stdout.write(`- ${e}${n}`);const t=n=>()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(n?H(`+ ${e}`):Q(`* ${e}`)),process.stdout.write("\n")};return{resolve:t(!0),reject:t(!1)}},[,,G,X]=process.argv;(()=>{if(!G||!X)return void console.log("Expected name of layer and name");const e=B[G];if(!e)return void console.log(`Unknown layer: ${G}`);const n=T("file copying");((e,n)=>{const{scaffold:t,getSrc:r}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...f(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,E.resolve)(n,e),s="string"==typeof t?t:JSON.stringify(t,null,2);(0,I.mkdirSync)((0,E.dirname)(r),{recursive:!0}),(0,I.writeFileSync)(r,s)}))})(e(),X),n.resolve(),(async(e,n)=>{const t=(0,E.resolve)(n),r=e=>new Promise((n=>{(0,U.exec)(e,{cwd:t},n)})),s=T("node_modules installing"," (this can take much time)");await r("npm i"),s.resolve();const o=T("raw text formatting");await r("npm run lint"),await r("npm run format-json"),o.resolve();const i=T("making the first commit");await r("git init"),await r("git add ."),await r(`git commit -m "${e} created"`),i.resolve()})(G,X).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="| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Build | `npm run build` |\n| Run application | `npm start` |\n| | |\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<Record<string, string>>(\n (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 },\n {}\n)\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"},836:e=>{e.exports="| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| | |\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 } 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 ? [] : 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="export 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"},642:e=>{e.exports="import { resolve } from 'path'\n\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 clean: true,\n },\n}\n\nexport const prodPlugins = [\n new MiniCssPlugin({ filename: '[contenthash].css' }),\n]\n"},247:e=>{e.exports="| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Run dev-server | `npm run serve` |\n| Build | `npm run build` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Format SCSS | `npm run format-scss` |\n| | |\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="| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Run dev-server | `npm run serve` |\n| Build | `npm run build` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Format SCSS | `npm run format-scss` |\n| | |\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(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";const e=JSON.parse('{"presets":["@babel/preset-env","@babel/preset-typescript"]}'),n=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,"no-throw-literal":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":"export","next":"*"},{"blankLine":"always","prev":"*","next":"export"},{"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"}]}}'),t=JSON.parse('{"semi":false,"singleQuote":true,"arrowParens":"avoid","quoteProps":"consistent"}'),s=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.17.9","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@types/jest":"^27.4.1","@typescript-eslint/eslint-plugin":"^5.21.0","@typescript-eslint/parser":"^5.21.0","babel-jest":"^28.0.2","eslint":"^8.14.0","eslint-config-prettier":"^8.5.0","eslint-import-resolver-typescript":"^2.7.1","eslint-plugin-import":"^2.26.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.0.2","prettier":"^2.6.2","ts-node":"^10.7.0","typescript":"^4.6.3"}}'),r=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":{"@/*":["./*"]}}}'),o="export const arraySum = (arr: number[]): number =>\n arr.reduce((acc, cur) => acc + cur)\n",i="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",a=()=>({scaffold:{"dev-helpers/alias.ts":"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<Record<string, string>>(\n (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 },\n {}\n)\n",".babelrc":e,".eslintrc":n,".prettierrc":t,".gitignore":".vscode\n.idea\n\nnode_modules\ndist\n\npackage-lock.json\n","index.d.ts":"","jest.config.ts":"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","package.json":s,"tsconfig.json":r},getSrc:()=>({"array-sum.ts":o,"array-sum.spec.ts":i}),getReadme:()=>"| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| | |\n"}),p=e=>e.scaffold["package.json"],l=e=>e.scaffold["tsconfig.json"].compilerOptions,c=(e,n)=>'<!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'.replace("{{ title }}",e).replace("{{ body }}",n),d='<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',m="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",u=()=>{const e=a(),n=l(e),t=p(e),{scripts:s,devDependencies:r}=t;return n.lib.push("dom"),e.scaffold["index.d.ts"]="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",s["format-scss"]="prettier **/*.scss --write",s.build="webpack",s.serve="webpack serve",t.devDependencies={...r,"@types/copy-webpack-plugin":"^10.1.0","@types/mini-css-extract-plugin":"^2.5.1","babel-loader":"^8.2.5","copy-webpack-plugin":"^10.2.4","css-loader":"^6.7.1","html-webpack-plugin":"^5.5.0","mini-css-extract-plugin":"^2.6.0",sass:"^1.51.0","sass-loader":"^12.6.0","style-loader":"^3.3.1",webpack:"^5.72.0","webpack-cli":"^4.9.2","webpack-dev-server":"^4.8.1"},{scaffold:{...e.scaffold,"dev-helpers/webpack-dev.ts":"export 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","dev-helpers/webpack-prod.ts":"import { resolve } from 'path'\n\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 clean: true,\n },\n}\n\nexport const prodPlugins = [\n new MiniCssPlugin({ filename: '[contenthash].css' }),\n]\n","webpack.config.ts":"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 } 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 ? [] : 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"},getSrc:()=>({"favicon.svg":d,"index.html":c("Frontend",'<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'),"main.scss":m,"main.ts":"import '@/main.scss'\n","array-sum.ts":o,"array-sum.spec.ts":i}),getReadme:()=>"| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Run dev-server | `npm run serve` |\n| Build | `npm run build` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Format SCSS | `npm run format-scss` |\n| | |\n"}},g={code:a,backend:()=>{const e=a(),n=p(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":"^17.0.29","babel-loader":"^8.2.5",webpack:"^5.72.0","webpack-cli":"^4.9.2"},{scaffold:{...e.scaffold,"dev-helpers/dependencies.ts":"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","dev-helpers/create-package.ts":"import { writeFileSync } from 'fs'\n\nimport { distPackageJson } from './dependencies'\n\nwriteFileSync('dist/package.json', distPackageJson)\n","webpack.config.ts":"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"},getSrc:()=>({"main.ts":"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","app.ts":"import { RequestListener } from 'http'\n\nexport const app: RequestListener = (_, res) => {\n res.write('It works!')\n res.end()\n}\n","app.spec.ts":"import { app } from '@/app'\n\ndescribe('app', () => {\n it('should be defined', () => {\n expect(app).toBeDefined()\n })\n})\n"}),getReadme:()=>"| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Build | `npm run build` |\n| Run application | `npm start` |\n| | |\n"}},frontend:u,react:()=>{const e=u(),n=l(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=p(e),{devDependencies:t,scripts:s}=n;s.lint="eslint . --ext .ts,.tsx --fix",n.devDependencies={...t,"@babel/preset-react":"^7.16.7","@types/react":"^18.0.8","@types/react-dom":"^18.0.0","eslint-plugin-react":"^7.29.4"},n.dependencies={react:"^18.1.0","react-dom":"^18.1.0"}})(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":'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',"main.ts":"import './main.scss'\n\nimport { renderApp } from './App'\n\nrenderApp(document.querySelector('.demo-app'))\n","main.scss":m,"favicon.svg":d,"index.html":c("React",'<div class="demo-app"></div>')}),getReadme:()=>"| | |\n|------------------------|:----------------------|\n| Install dependencies | `npm i` |\n| Run tests | `npm run test` |\n| Check types | `npm run ts` |\n| Run dev-server | `npm run serve` |\n| Build | `npm run build` |\n| Lint | `npm run lint` |\n| Format JSON | `npm run format-json` |\n| Format SCSS | `npm run format-scss` |\n| | |\n"}}},f=require("path"),b=require("fs"),v=require("child_process"),y=e=>n=>`[${e}m${n}`,h=y(92),x=y(91),w=(e,n="...")=>{process.stdout.write(`- ${e}${n}`);const t=n=>()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(n?h(`+ ${e}`):x(`* ${e}`)),process.stdout.write("\n")};return{resolve:t(!0),reject:t(!1)}},[,,k,j]=process.argv;(()=>{if(!k||!j)return void console.log("Expected name of layer and name");const e=g[k];if(!e)return void console.log(`Unknown layer: ${k}`);const n=w("file copying");((e,n)=>{const{scaffold:t,getSrc:s}=e;((e,n)=>{e.scaffold["package.json"]={name:n,...p(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,f.resolve)(n,e),r="string"==typeof t?t:JSON.stringify(t,null,2);(0,b.mkdirSync)((0,f.dirname)(s),{recursive:!0}),(0,b.writeFileSync)(s,r)}))})(e(),j),n.resolve(),(async(e,n)=>{const t=(0,f.resolve)(n),s=e=>new Promise((n=>{(0,v.exec)(e,{cwd:t},n)})),r=w("node_modules installing"," (this can take much time)");await s("npm i"),r.resolve();const o=w("raw text formatting");await s("npm run lint"),await s("npm run format-json"),o.resolve();const i=w("making the first commit");await s("git init"),await s("git add ."),await s(`git commit -m "${e} created"`),i.resolve()})(k,j).then((()=>{console.log(""),console.log("done.")}))})()})();
{
"name": "create-layer",
"version": "1.0.13",
"version": "1.0.14",
"description": "generator of starters",

@@ -5,0 +5,0 @@ "preferGlobal": true,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc