@whook/create 9.0.1 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/create.js +2 -2
- package/dist/index.js +46 -68
- package/dist/index.js.map +1 -1
- package/dist/services/author.js +46 -72
- package/dist/services/author.js.map +1 -1
- package/dist/services/author.test.js +86 -92
- package/dist/services/author.test.js.map +1 -1
- package/dist/services/createWhook.d.ts +8 -11
- package/dist/services/createWhook.js +124 -144
- package/dist/services/createWhook.js.map +1 -1
- package/dist/services/createWhook.test.js +392 -506
- package/dist/services/createWhook.test.js.map +1 -1
- package/dist/services/project.d.ts +2 -2
- package/dist/services/project.js +40 -62
- package/dist/services/project.js.map +1 -1
- package/dist/services/project.test.js +73 -80
- package/dist/services/project.test.js.map +1 -1
- package/package.json +46 -92
- package/src/index.ts +23 -17
- package/src/services/__snapshots__/author.test.ts.snap +3 -3
- package/src/services/__snapshots__/createWhook.test.ts.snap +4 -4
- package/src/services/author.test.ts +8 -6
- package/src/services/author.ts +2 -2
- package/src/services/createWhook.test.ts +197 -312
- package/src/services/createWhook.ts +12 -12
- package/src/services/project.test.ts +11 -6
- package/src/services/project.ts +3 -2
- package/dist/index.mjs +0 -47
- package/dist/index.mjs.map +0 -1
- package/dist/services/author.mjs +0 -63
- package/dist/services/author.mjs.map +0 -1
- package/dist/services/author.test.mjs +0 -94
- package/dist/services/author.test.mjs.map +0 -1
- package/dist/services/createWhook.mjs +0 -135
- package/dist/services/createWhook.mjs.map +0 -1
- package/dist/services/createWhook.test.mjs +0 -834
- package/dist/services/createWhook.test.mjs.map +0 -1
- package/dist/services/project.mjs +0 -50
- package/dist/services/project.mjs.map +0 -1
- package/dist/services/project.test.mjs +0 -80
- package/dist/services/project.test.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createWhook.test.mjs","names":["initCreateWhook","YError","_packageJSON","require","describe","CWD","SOURCE_DIR","packageJSON","dependencies","author","name","email","project","directory","writeFile","jest","fn","readFile","readdir","exec","copy","axios","ora","oraInstance","start","stopAndPersist","log","beforeEach","mockReset","mockReturnValue","mockResolvedValue","Buffer","from","it","mockResolvedValueOnce","JSON","stringify","mockImplementationOnce","_","_2","filter","Promise","all","map","fileName","data","undefined","cb","createWhook","expect","parse","mock","calls","find","call","endsWith","toMatchInlineSnapshot","copyCalls","writeFileCalls","readFileCalls","execCalls","oraCalls","oraStartCalls","oraStopAndPersistCalls","logCalls","type","readdirCalls","toMatchSnapshot","mockRejectedValueOnce","err","errorCode","code","errorParams","params"],"sources":["../../src/services/createWhook.test.ts"],"sourcesContent":["import initCreateWhook from './createWhook';\nimport YError from 'yerror';\n\n// eslint-disable-next-line\nconst _packageJSON = require('@whook/example/package.json');\n\ndescribe('initCreateWhook', () => {\n const CWD = '/home/whoiam/projects/';\n const SOURCE_DIR = '/var/lib/node/node_modules/whook-example';\n const packageJSON = {\n ..._packageJSON,\n dependencies: {\n ..._packageJSON.dependencies,\n '@whook/authorization': '<current_version>',\n '@whook/cli': '<current_version>',\n '@whook/cors': '<current_version>',\n '@whook/http-router': '<current_version>',\n '@whook/http-transaction': '<current_version>',\n '@whook/swagger-ui': '<current_version>',\n '@whook/whook': '<current_version>',\n },\n };\n const author = {\n name: 'Wayne Campbell',\n email: 'wayne@warner.com',\n };\n const project = {\n name: 'super-project',\n directory: '/home/whoiam/projects/yolo',\n };\n const writeFile = jest.fn();\n const readFile = jest.fn();\n const readdir = jest.fn();\n const exec = jest.fn();\n const copy = jest.fn();\n const axios = jest.fn();\n const ora = jest.fn();\n const oraInstance = {\n start: jest.fn(),\n stopAndPersist: jest.fn(),\n };\n const log = jest.fn();\n\n beforeEach(() => {\n axios.mockReset();\n writeFile.mockReset();\n readFile.mockReset();\n readdir.mockReset();\n exec.mockReset();\n copy.mockReset();\n log.mockReset();\n ora.mockReset();\n ora.mockReturnValue(oraInstance);\n oraInstance.start.mockReset();\n oraInstance.start.mockReturnValue(oraInstance);\n oraInstance.stopAndPersist.mockReset();\n readFile.mockResolvedValue(\n Buffer.from(`\n# test\n> yolo\n\n[//]: # (::contents:start)\n\nYOLO\n\n[//]: # (::contents:end)\n\n# Authors\nMr Bean\n\n `),\n );\n });\n\n it('should work', async () => {\n readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));\n readdir.mockResolvedValueOnce(['development', 'production']);\n copy.mockImplementationOnce((_, _2, { filter }) =>\n Promise.all(\n [\n 'package.json',\n 'package-lock.json',\n 'LICENSE',\n 'dist/index.js',\n 'src/index.js',\n 'coverage/index.html',\n 'node_modules/whook/index.js',\n ].map((fileName) =>\n filter(\n `${SOURCE_DIR}/${fileName}`,\n `${project.directory}/${fileName}`,\n ),\n ),\n ),\n );\n axios.mockResolvedValueOnce({\n data: 'node_modules',\n });\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n exec.mockImplementationOnce((_, _2, cb) =>\n cb(null, 'Initialized an empty git repository!'),\n );\n exec.mockImplementationOnce((_, _2, cb) =>\n cb(null, 'Installed dependencies!'),\n );\n\n const createWhook = await initCreateWhook({\n CWD,\n SOURCE_DIR,\n author,\n project,\n writeFile,\n readFile,\n readdir,\n exec: exec as any,\n copy,\n axios: axios as any,\n ora: ora as any,\n log,\n });\n\n await createWhook();\n\n expect(\n JSON.parse(\n writeFile.mock.calls.find((call) =>\n call[0].endsWith('package.json'),\n )[1],\n ),\n ).toMatchInlineSnapshot(`\n Object {\n \"author\": Object {\n \"email\": \"wayne@warner.com\",\n \"name\": \"Wayne Campbell\",\n },\n \"babel\": Object {\n \"env\": Object {\n \"cjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": \"commonjs\",\n \"targets\": Object {\n \"node\": \"10\",\n },\n },\n ],\n ],\n },\n \"mjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": false,\n \"targets\": Object {\n \"node\": \"12\",\n },\n },\n ],\n ],\n },\n },\n \"plugins\": Array [\n \"@babel/proposal-class-properties\",\n \"@babel/plugin-proposal-object-rest-spread\",\n \"babel-plugin-knifecycle\",\n ],\n \"presets\": Array [\n \"@babel/typescript\",\n Array [\n \"@babel/env\",\n Object {\n \"targets\": Object {\n \"node\": \"12.19.0\",\n },\n },\n ],\n ],\n \"sourceMaps\": true,\n },\n \"dependencies\": Object {\n \"@whook/authorization\": \"<current_version>\",\n \"@whook/cli\": \"<current_version>\",\n \"@whook/cors\": \"<current_version>\",\n \"@whook/http-router\": \"<current_version>\",\n \"@whook/http-server\": \"^9.0.0\",\n \"@whook/http-transaction\": \"<current_version>\",\n \"@whook/swagger-ui\": \"<current_version>\",\n \"@whook/whook\": \"<current_version>\",\n \"common-services\": \"^10.0.2\",\n \"http-auth-utils\": \"^3.0.3\",\n \"jwt-service\": \"^8.0.1\",\n \"knifecycle\": \"^12.0.4\",\n \"openapi-schema-validator\": \"^11.0.1\",\n \"openapi-types\": \"^11.0.1\",\n \"strict-qs\": \"^6.1.5\",\n \"type-fest\": \"^2.13.0\",\n \"yerror\": \"^6.0.2\",\n \"yhttperror\": \"^6.0.3\",\n },\n \"description\": \"A new Whook project\",\n \"devDependencies\": Object {\n \"@babel/cli\": \"^7.17.10\",\n \"@babel/core\": \"^7.18.2\",\n \"@babel/eslint-parser\": \"^7.18.2\",\n \"@babel/node\": \"^7.13.13\",\n \"@babel/plugin-proposal-class-properties\": \"^7.17.12\",\n \"@babel/plugin-proposal-object-rest-spread\": \"^7.18.0\",\n \"@babel/plugin-syntax-dynamic-import\": \"^7.8.3\",\n \"@babel/plugin-syntax-import-meta\": \"^7.10.4\",\n \"@babel/preset-env\": \"^7.18.2\",\n \"@babel/preset-typescript\": \"^7.17.12\",\n \"@babel/register\": \"^7.17.7\",\n \"@types/jest\": \"^27.0.2\",\n \"@typescript-eslint/eslint-plugin\": \"^5.26.0\",\n \"@typescript-eslint/parser\": \"^5.26.0\",\n \"axios\": \"^0.27.2\",\n \"babel-plugin-knifecycle\": \"^5.0.3\",\n \"chokidar\": \"^3.5.1\",\n \"eslint\": \"^8.16.0\",\n \"eslint-plugin-prettier\": \"^4.0.0\",\n \"jest\": \"^28.1.0\",\n \"jsarch\": \"^5.0.1\",\n \"parse-gitignore\": \"^1.0.1\",\n \"prettier\": \"^2.6.2\",\n \"rimraf\": \"^3.0.2\",\n \"schema2dts\": \"^4.1.1\",\n \"typescript\": \"^4.7.2\",\n },\n \"engines\": Object {\n \"node\": \">=12.19.0\",\n },\n \"eslintConfig\": Object {\n \"env\": Object {\n \"es6\": true,\n \"jest\": true,\n \"mocha\": true,\n \"node\": true,\n },\n \"extends\": Array [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/eslint-recommended\",\n \"plugin:@typescript-eslint/recommended\",\n ],\n \"ignorePatterns\": Array [\n \"*.d.ts\",\n ],\n \"parser\": \"@typescript-eslint/parser\",\n \"parserOptions\": Object {\n \"ecmaVersion\": 2018,\n \"modules\": true,\n \"sourceType\": \"module\",\n },\n \"plugins\": Array [\n \"prettier\",\n ],\n \"rules\": Object {\n \"prettier/prettier\": \"error\",\n },\n },\n \"files\": Array [\n \"bin\",\n \"dist\",\n \"src\",\n \"LICENSE\",\n \"README.md\",\n \"CHANGELOG.md\",\n ],\n \"jest\": Object {\n \"coverageReporters\": Array [\n \"lcov\",\n \"html\",\n ],\n \"roots\": Array [\n \"<rootDir>/src\",\n ],\n \"testEnvironment\": \"node\",\n \"testPathIgnorePatterns\": Array [\n \"/node_modules/\",\n ],\n },\n \"keywords\": Array [\n \"whook\",\n ],\n \"license\": \"SEE LICENSE\",\n \"main\": \"dist/index\",\n \"module\": \"dist/index.mjs\",\n \"name\": \"super-project\",\n \"prettier\": Object {\n \"printWidth\": 80,\n \"proseWrap\": \"always\",\n \"semi\": true,\n \"singleQuote\": true,\n \"trailingComma\": \"all\",\n },\n \"private\": true,\n \"scripts\": Object {\n \"apitypes\": \"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\",\n \"architecture\": \"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\",\n \"build\": \"npm run compile && NODE_ENV=\\${NODE_ENV:-development} node bin/build\",\n \"compile\": \"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\",\n \"compile:cjs\": \"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"compile:mjs\": \"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"cover\": \"npm run jest -- --coverage\",\n \"debug\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\",\n \"dev\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\",\n \"genPackagelock\": \"npm i --package-lock-only\",\n \"jest\": \"NODE_ENV=test jest\",\n \"lint\": \"eslint 'src/**/*.ts'\",\n \"prettier\": \"prettier --write 'src/**/*.ts'\",\n \"start\": \"NODE_ENV=\\${NODE_ENV:-development} node bin/start\",\n \"test\": \"npm run jest\",\n \"types\": \"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\",\n \"watch\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\",\n \"whook\": \"NODE_ENV=\\${NODE_ENV:-development} whook\",\n \"whook-dev\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\",\n \"whook-repl\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\",\n },\n \"types\": \"dist/index.d.ts\",\n \"version\": \"0.0.0\",\n }\n `);\n expect({\n copyCalls: copy.mock.calls,\n writeFileCalls: writeFile.mock.calls,\n readFileCalls: readFile.mock.calls,\n execCalls: exec.mock.calls,\n oraCalls: ora.mock.calls,\n oraStartCalls: oraInstance.start.mock.calls,\n oraStopAndPersistCalls: oraInstance.stopAndPersist.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n readdirCalls: readFile.mock.calls,\n }).toMatchSnapshot();\n });\n\n it('should handle network issues', async () => {\n readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));\n readdir.mockResolvedValueOnce(['development', 'production']);\n copy.mockImplementationOnce((_, _2, { filter }) =>\n Promise.all(\n [\n 'package.json',\n 'package-lock.json',\n 'LICENSE',\n 'dist/index.js',\n 'src/index.js',\n 'coverage/index.html',\n 'node_modules/whook/index.js',\n ].map((fileName) =>\n filter(\n `${SOURCE_DIR}/${fileName}`,\n `${project.directory}/${fileName}`,\n ),\n ),\n ),\n );\n axios.mockRejectedValueOnce(new YError('E_NETWORK'));\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n exec.mockImplementationOnce((_, _2, cb) => cb(new YError('E_ACCESS')));\n exec.mockImplementationOnce((_, _2, cb) =>\n cb(null, 'Installed dependencies!'),\n );\n\n const createWhook = await initCreateWhook({\n CWD,\n SOURCE_DIR,\n author,\n project,\n writeFile,\n readFile,\n readdir,\n exec: exec as any,\n copy,\n axios: axios as any,\n ora: ora as any,\n log,\n });\n\n await createWhook();\n\n expect(\n JSON.parse(\n writeFile.mock.calls.find((call) =>\n call[0].endsWith('package.json'),\n )[1],\n ),\n ).toMatchInlineSnapshot(`\n Object {\n \"author\": Object {\n \"email\": \"wayne@warner.com\",\n \"name\": \"Wayne Campbell\",\n },\n \"babel\": Object {\n \"env\": Object {\n \"cjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": \"commonjs\",\n \"targets\": Object {\n \"node\": \"10\",\n },\n },\n ],\n ],\n },\n \"mjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": false,\n \"targets\": Object {\n \"node\": \"12\",\n },\n },\n ],\n ],\n },\n },\n \"plugins\": Array [\n \"@babel/proposal-class-properties\",\n \"@babel/plugin-proposal-object-rest-spread\",\n \"babel-plugin-knifecycle\",\n ],\n \"presets\": Array [\n \"@babel/typescript\",\n Array [\n \"@babel/env\",\n Object {\n \"targets\": Object {\n \"node\": \"12.19.0\",\n },\n },\n ],\n ],\n \"sourceMaps\": true,\n },\n \"dependencies\": Object {\n \"@whook/authorization\": \"<current_version>\",\n \"@whook/cli\": \"<current_version>\",\n \"@whook/cors\": \"<current_version>\",\n \"@whook/http-router\": \"<current_version>\",\n \"@whook/http-server\": \"^9.0.0\",\n \"@whook/http-transaction\": \"<current_version>\",\n \"@whook/swagger-ui\": \"<current_version>\",\n \"@whook/whook\": \"<current_version>\",\n \"common-services\": \"^10.0.2\",\n \"http-auth-utils\": \"^3.0.3\",\n \"jwt-service\": \"^8.0.1\",\n \"knifecycle\": \"^12.0.4\",\n \"openapi-schema-validator\": \"^11.0.1\",\n \"openapi-types\": \"^11.0.1\",\n \"strict-qs\": \"^6.1.5\",\n \"type-fest\": \"^2.13.0\",\n \"yerror\": \"^6.0.2\",\n \"yhttperror\": \"^6.0.3\",\n },\n \"description\": \"A new Whook project\",\n \"devDependencies\": Object {\n \"@babel/cli\": \"^7.17.10\",\n \"@babel/core\": \"^7.18.2\",\n \"@babel/eslint-parser\": \"^7.18.2\",\n \"@babel/node\": \"^7.13.13\",\n \"@babel/plugin-proposal-class-properties\": \"^7.17.12\",\n \"@babel/plugin-proposal-object-rest-spread\": \"^7.18.0\",\n \"@babel/plugin-syntax-dynamic-import\": \"^7.8.3\",\n \"@babel/plugin-syntax-import-meta\": \"^7.10.4\",\n \"@babel/preset-env\": \"^7.18.2\",\n \"@babel/preset-typescript\": \"^7.17.12\",\n \"@babel/register\": \"^7.17.7\",\n \"@types/jest\": \"^27.0.2\",\n \"@typescript-eslint/eslint-plugin\": \"^5.26.0\",\n \"@typescript-eslint/parser\": \"^5.26.0\",\n \"axios\": \"^0.27.2\",\n \"babel-plugin-knifecycle\": \"^5.0.3\",\n \"chokidar\": \"^3.5.1\",\n \"eslint\": \"^8.16.0\",\n \"eslint-plugin-prettier\": \"^4.0.0\",\n \"jest\": \"^28.1.0\",\n \"jsarch\": \"^5.0.1\",\n \"parse-gitignore\": \"^1.0.1\",\n \"prettier\": \"^2.6.2\",\n \"rimraf\": \"^3.0.2\",\n \"schema2dts\": \"^4.1.1\",\n \"typescript\": \"^4.7.2\",\n },\n \"engines\": Object {\n \"node\": \">=12.19.0\",\n },\n \"eslintConfig\": Object {\n \"env\": Object {\n \"es6\": true,\n \"jest\": true,\n \"mocha\": true,\n \"node\": true,\n },\n \"extends\": Array [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/eslint-recommended\",\n \"plugin:@typescript-eslint/recommended\",\n ],\n \"ignorePatterns\": Array [\n \"*.d.ts\",\n ],\n \"parser\": \"@typescript-eslint/parser\",\n \"parserOptions\": Object {\n \"ecmaVersion\": 2018,\n \"modules\": true,\n \"sourceType\": \"module\",\n },\n \"plugins\": Array [\n \"prettier\",\n ],\n \"rules\": Object {\n \"prettier/prettier\": \"error\",\n },\n },\n \"files\": Array [\n \"bin\",\n \"dist\",\n \"src\",\n \"LICENSE\",\n \"README.md\",\n \"CHANGELOG.md\",\n ],\n \"jest\": Object {\n \"coverageReporters\": Array [\n \"lcov\",\n \"html\",\n ],\n \"roots\": Array [\n \"<rootDir>/src\",\n ],\n \"testEnvironment\": \"node\",\n \"testPathIgnorePatterns\": Array [\n \"/node_modules/\",\n ],\n },\n \"keywords\": Array [\n \"whook\",\n ],\n \"license\": \"SEE LICENSE\",\n \"main\": \"dist/index\",\n \"module\": \"dist/index.mjs\",\n \"name\": \"super-project\",\n \"prettier\": Object {\n \"printWidth\": 80,\n \"proseWrap\": \"always\",\n \"semi\": true,\n \"singleQuote\": true,\n \"trailingComma\": \"all\",\n },\n \"private\": true,\n \"scripts\": Object {\n \"apitypes\": \"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\",\n \"architecture\": \"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\",\n \"build\": \"npm run compile && NODE_ENV=\\${NODE_ENV:-development} node bin/build\",\n \"compile\": \"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\",\n \"compile:cjs\": \"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"compile:mjs\": \"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"cover\": \"npm run jest -- --coverage\",\n \"debug\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\",\n \"dev\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\",\n \"genPackagelock\": \"npm i --package-lock-only\",\n \"jest\": \"NODE_ENV=test jest\",\n \"lint\": \"eslint 'src/**/*.ts'\",\n \"prettier\": \"prettier --write 'src/**/*.ts'\",\n \"start\": \"NODE_ENV=\\${NODE_ENV:-development} node bin/start\",\n \"test\": \"npm run jest\",\n \"types\": \"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\",\n \"watch\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\",\n \"whook\": \"NODE_ENV=\\${NODE_ENV:-development} whook\",\n \"whook-dev\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\",\n \"whook-repl\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\",\n },\n \"types\": \"dist/index.d.ts\",\n \"version\": \"0.0.0\",\n }\n `);\n expect({\n copyCalls: copy.mock.calls,\n writeFileCalls: writeFile.mock.calls,\n readFileCalls: readFile.mock.calls,\n execCalls: exec.mock.calls,\n oraCalls: ora.mock.calls,\n oraStartCalls: oraInstance.start.mock.calls,\n oraStopAndPersistCalls: oraInstance.stopAndPersist.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n readdirCalls: readFile.mock.calls,\n }).toMatchSnapshot();\n });\n\n it('should handle git initialization problems', async () => {\n readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));\n readdir.mockResolvedValueOnce(['development', 'production']);\n copy.mockResolvedValueOnce(new YError('E_ACCESS'));\n axios.mockResolvedValueOnce({\n data: 'node_modules',\n });\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n exec.mockImplementationOnce((_, _2, cb) => cb(new YError('E_ACCESS')));\n exec.mockImplementationOnce((_, _2, cb) =>\n cb(null, 'Installed dependencies!'),\n );\n\n const createWhook = await initCreateWhook({\n CWD,\n SOURCE_DIR,\n author,\n project,\n writeFile,\n readFile,\n readdir,\n exec: exec as any,\n copy,\n axios: axios as any,\n ora: ora as any,\n log,\n });\n\n await createWhook();\n\n expect(\n JSON.parse(\n writeFile.mock.calls.find((call) =>\n call[0].endsWith('package.json'),\n )[1],\n ),\n ).toMatchInlineSnapshot(`\n Object {\n \"author\": Object {\n \"email\": \"wayne@warner.com\",\n \"name\": \"Wayne Campbell\",\n },\n \"babel\": Object {\n \"env\": Object {\n \"cjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": \"commonjs\",\n \"targets\": Object {\n \"node\": \"10\",\n },\n },\n ],\n ],\n },\n \"mjs\": Object {\n \"presets\": Array [\n Array [\n \"@babel/env\",\n Object {\n \"modules\": false,\n \"targets\": Object {\n \"node\": \"12\",\n },\n },\n ],\n ],\n },\n },\n \"plugins\": Array [\n \"@babel/proposal-class-properties\",\n \"@babel/plugin-proposal-object-rest-spread\",\n \"babel-plugin-knifecycle\",\n ],\n \"presets\": Array [\n \"@babel/typescript\",\n Array [\n \"@babel/env\",\n Object {\n \"targets\": Object {\n \"node\": \"12.19.0\",\n },\n },\n ],\n ],\n \"sourceMaps\": true,\n },\n \"dependencies\": Object {\n \"@whook/authorization\": \"<current_version>\",\n \"@whook/cli\": \"<current_version>\",\n \"@whook/cors\": \"<current_version>\",\n \"@whook/http-router\": \"<current_version>\",\n \"@whook/http-server\": \"^9.0.0\",\n \"@whook/http-transaction\": \"<current_version>\",\n \"@whook/swagger-ui\": \"<current_version>\",\n \"@whook/whook\": \"<current_version>\",\n \"common-services\": \"^10.0.2\",\n \"http-auth-utils\": \"^3.0.3\",\n \"jwt-service\": \"^8.0.1\",\n \"knifecycle\": \"^12.0.4\",\n \"openapi-schema-validator\": \"^11.0.1\",\n \"openapi-types\": \"^11.0.1\",\n \"strict-qs\": \"^6.1.5\",\n \"type-fest\": \"^2.13.0\",\n \"yerror\": \"^6.0.2\",\n \"yhttperror\": \"^6.0.3\",\n },\n \"description\": \"A new Whook project\",\n \"devDependencies\": Object {\n \"@babel/cli\": \"^7.17.10\",\n \"@babel/core\": \"^7.18.2\",\n \"@babel/eslint-parser\": \"^7.18.2\",\n \"@babel/node\": \"^7.13.13\",\n \"@babel/plugin-proposal-class-properties\": \"^7.17.12\",\n \"@babel/plugin-proposal-object-rest-spread\": \"^7.18.0\",\n \"@babel/plugin-syntax-dynamic-import\": \"^7.8.3\",\n \"@babel/plugin-syntax-import-meta\": \"^7.10.4\",\n \"@babel/preset-env\": \"^7.18.2\",\n \"@babel/preset-typescript\": \"^7.17.12\",\n \"@babel/register\": \"^7.17.7\",\n \"@types/jest\": \"^27.0.2\",\n \"@typescript-eslint/eslint-plugin\": \"^5.26.0\",\n \"@typescript-eslint/parser\": \"^5.26.0\",\n \"axios\": \"^0.27.2\",\n \"babel-plugin-knifecycle\": \"^5.0.3\",\n \"chokidar\": \"^3.5.1\",\n \"eslint\": \"^8.16.0\",\n \"eslint-plugin-prettier\": \"^4.0.0\",\n \"jest\": \"^28.1.0\",\n \"jsarch\": \"^5.0.1\",\n \"parse-gitignore\": \"^1.0.1\",\n \"prettier\": \"^2.6.2\",\n \"rimraf\": \"^3.0.2\",\n \"schema2dts\": \"^4.1.1\",\n \"typescript\": \"^4.7.2\",\n },\n \"engines\": Object {\n \"node\": \">=12.19.0\",\n },\n \"eslintConfig\": Object {\n \"env\": Object {\n \"es6\": true,\n \"jest\": true,\n \"mocha\": true,\n \"node\": true,\n },\n \"extends\": Array [\n \"eslint:recommended\",\n \"plugin:@typescript-eslint/eslint-recommended\",\n \"plugin:@typescript-eslint/recommended\",\n ],\n \"ignorePatterns\": Array [\n \"*.d.ts\",\n ],\n \"parser\": \"@typescript-eslint/parser\",\n \"parserOptions\": Object {\n \"ecmaVersion\": 2018,\n \"modules\": true,\n \"sourceType\": \"module\",\n },\n \"plugins\": Array [\n \"prettier\",\n ],\n \"rules\": Object {\n \"prettier/prettier\": \"error\",\n },\n },\n \"files\": Array [\n \"bin\",\n \"dist\",\n \"src\",\n \"LICENSE\",\n \"README.md\",\n \"CHANGELOG.md\",\n ],\n \"jest\": Object {\n \"coverageReporters\": Array [\n \"lcov\",\n \"html\",\n ],\n \"roots\": Array [\n \"<rootDir>/src\",\n ],\n \"testEnvironment\": \"node\",\n \"testPathIgnorePatterns\": Array [\n \"/node_modules/\",\n ],\n },\n \"keywords\": Array [\n \"whook\",\n ],\n \"license\": \"SEE LICENSE\",\n \"main\": \"dist/index\",\n \"module\": \"dist/index.mjs\",\n \"name\": \"super-project\",\n \"prettier\": Object {\n \"printWidth\": 80,\n \"proseWrap\": \"always\",\n \"semi\": true,\n \"singleQuote\": true,\n \"trailingComma\": \"all\",\n },\n \"private\": true,\n \"scripts\": Object {\n \"apitypes\": \"npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts\",\n \"architecture\": \"jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md\",\n \"build\": \"npm run compile && NODE_ENV=\\${NODE_ENV:-development} node bin/build\",\n \"compile\": \"rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs\",\n \"compile:cjs\": \"babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"compile:mjs\": \"babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src\",\n \"cover\": \"npm run jest -- --coverage\",\n \"debug\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev\",\n \"dev\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev\",\n \"genPackagelock\": \"npm i --package-lock-only\",\n \"jest\": \"NODE_ENV=test jest\",\n \"lint\": \"eslint 'src/**/*.ts'\",\n \"prettier\": \"prettier --write 'src/**/*.ts'\",\n \"start\": \"NODE_ENV=\\${NODE_ENV:-development} node bin/start\",\n \"test\": \"npm run jest\",\n \"types\": \"rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist\",\n \"watch\": \"NODE_ENV=\\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch\",\n \"whook\": \"NODE_ENV=\\${NODE_ENV:-development} whook\",\n \"whook-dev\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js\",\n \"whook-repl\": \"PROJECT_SRC=\\\\\"$PWD/src\\\\\" NODE_ENV=\\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js\",\n },\n \"types\": \"dist/index.d.ts\",\n \"version\": \"0.0.0\",\n }\n `);\n expect({\n copyCalls: copy.mock.calls,\n writeFileCalls: writeFile.mock.calls,\n readFileCalls: readFile.mock.calls,\n execCalls: exec.mock.calls,\n oraCalls: ora.mock.calls,\n oraStartCalls: oraInstance.start.mock.calls,\n oraStopAndPersistCalls: oraInstance.stopAndPersist.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n readdirCalls: readFile.mock.calls,\n }).toMatchSnapshot();\n });\n\n it('should fail with access problems', async () => {\n readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));\n readdir.mockResolvedValueOnce(['development', 'production']);\n copy.mockRejectedValueOnce(new YError('E_ACCESS'));\n axios.mockResolvedValueOnce({\n data: 'node_modules',\n });\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n writeFile.mockResolvedValueOnce(undefined);\n exec.mockImplementationOnce((_, _2, cb) => cb(null, ''));\n exec.mockImplementationOnce((_, _2, cb) =>\n cb(null, 'Installed dependencies!'),\n );\n\n try {\n const createWhook = await initCreateWhook({\n CWD,\n SOURCE_DIR,\n author,\n project,\n writeFile,\n readFile,\n readdir,\n exec: exec as any,\n copy,\n axios: axios as any,\n ora: ora as any,\n log,\n });\n\n await createWhook();\n\n throw new YError('E_UNEXPECTED_SUCCESS');\n } catch (err) {\n expect({\n errorCode: (err as YError).code,\n errorParams: (err as YError).params,\n }).toMatchInlineSnapshot(`\n Object {\n \"errorCode\": \"E_ACCESS\",\n \"errorParams\": Array [],\n }\n `);\n expect({\n copyCalls: copy.mock.calls,\n writeFileCalls: writeFile.mock.calls,\n readFileCalls: readFile.mock.calls,\n execCalls: exec.mock.calls,\n oraCalls: ora.mock.calls,\n oraStartCalls: oraInstance.start.mock.calls,\n oraStopAndPersistCalls: oraInstance.stopAndPersist.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n readdirCalls: readdir.mock.calls,\n }).toMatchSnapshot();\n }\n });\n});\n"],"mappings":";;;;;;AAAA,OAAOA,eAAP,MAA4B,eAA5B;AACA,OAAOC,MAAP,MAAmB,QAAnB,C,CAEA;;AACA,MAAMC,YAAY,GAAGC,OAAO,CAAC,6BAAD,CAA5B;;AAEAC,QAAQ,CAAC,iBAAD,EAAoB,MAAM;EAChC,MAAMC,GAAG,GAAG,wBAAZ;EACA,MAAMC,UAAU,GAAG,0CAAnB;;EACA,MAAMC,WAAW,mCACZL,YADY;IAEfM,YAAY,kCACPN,YAAY,CAACM,YADN;MAEV,wBAAwB,mBAFd;MAGV,cAAc,mBAHJ;MAIV,eAAe,mBAJL;MAKV,sBAAsB,mBALZ;MAMV,2BAA2B,mBANjB;MAOV,qBAAqB,mBAPX;MAQV,gBAAgB;IARN;EAFG,EAAjB;;EAaA,MAAMC,MAAM,GAAG;IACbC,IAAI,EAAE,gBADO;IAEbC,KAAK,EAAE;EAFM,CAAf;EAIA,MAAMC,OAAO,GAAG;IACdF,IAAI,EAAE,eADQ;IAEdG,SAAS,EAAE;EAFG,CAAhB;EAIA,MAAMC,SAAS,GAAGC,IAAI,CAACC,EAAL,EAAlB;EACA,MAAMC,QAAQ,GAAGF,IAAI,CAACC,EAAL,EAAjB;EACA,MAAME,OAAO,GAAGH,IAAI,CAACC,EAAL,EAAhB;EACA,MAAMG,IAAI,GAAGJ,IAAI,CAACC,EAAL,EAAb;EACA,MAAMI,IAAI,GAAGL,IAAI,CAACC,EAAL,EAAb;EACA,MAAMK,KAAK,GAAGN,IAAI,CAACC,EAAL,EAAd;EACA,MAAMM,GAAG,GAAGP,IAAI,CAACC,EAAL,EAAZ;EACA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAxMI;IAyMAP,MAAM,CAAC;MACLQ,SAAS,EAAErC,IAAI,CAAC+B,IAAL,CAAUC,KADhB;MAELM,cAAc,EAAE5C,SAAS,CAACqC,IAAV,CAAeC,KAF1B;MAGLO,aAAa,EAAE1C,QAAQ,CAACkC,IAAT,CAAcC,KAHxB;MAILQ,SAAS,EAAEzC,IAAI,CAACgC,IAAL,CAAUC,KAJhB;MAKLS,QAAQ,EAAEvC,GAAG,CAAC6B,IAAJ,CAASC,KALd;MAMLU,aAAa,EAAEvC,WAAW,CAACC,KAAZ,CAAkB2B,IAAlB,CAAuBC,KANjC;MAOLW,sBAAsB,EAAExC,WAAW,CAACE,cAAZ,CAA2B0B,IAA3B,CAAgCC,KAPnD;MAQLY,QAAQ,EAAEtC,GAAG,CAACyB,IAAJ,CAASC,KAAT,CAAeZ,MAAf,CAAsB,CAAC,CAACyB,IAA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CG,MAHwC;MAIxCG,OAJwC;MAKxCE,SALwC;MAMxCG,QANwC;MAOxCC,OAPwC;MAQxCC,IAAI,EAAEA,IARkC;MASxCC,IATwC;MAUxCC,KAAK,EAAEA,KAViC;MAWxCC,GAAG,EAAEA,GAXmC;MAYxCI;IAZwC,CAAD,CAAzC;IAeA,MAAMsB,WAAW,EAAjB;IAEAC,MAAM,CACJd,IAAI,CAACe,KAAL,CACEpC,SAAS,CAACqC,IAAV,CAAeC,KAAf,CAAqBC,IAArB,CAA2BC,IAAD,IACxBA,IAAI,CAAC,CAAD,CAAJ,CAAQC,QAAR,CAAiB,cAAjB,CADF,EAEE,CAFF,CADF,CADI,CAAN,CAMEC,qBANF,CAMyB;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAxMI;IAyMAP,MAAM,CAAC;MACLQ,SAAS,EAAErC,IAAI,CAAC+B,IAAL,CAAUC,KADhB;MAELM,cAAc,EAAE5C,SAAS,CAACqC,IAAV,CAAeC,KAF1B;MAGLO,aAAa,EAAE1C,QAAQ,CAACkC,IAAT,CAAcC,KAHxB;MAILQ,SAAS,EAAEzC,IAAI,CAACgC,IAAL,CAAUC,KAJhB;MAKLS,QAAQ,EAAEvC,GAAG,CAAC6B,IAAJ,CAASC,KALd;MAMLU,aAAa,EAAEvC,WAAW,CAACC,KAAZ,CAAkB2B,IAAlB,CAAuBC,KANjC;MAOLW,sBAAsB,EAAExC,WAAW,CAACE,cAAZ,CAA2B0B,IAA3B,CAAgCC,KAPnD;MAQLY,QAAQ,EAAEtC,GAAG,CAACyB,IAAJ,CAASC,KAAT,CAAeZ,MAAf,CAAsB,CAAC,CAACyB,IAAD,CAAD,KAAY,CAACA,IAAI,CAACV,QAAL,CAAc,OAAd,CAAnC,CARL;MASLW,YAAY,EAAEjD,QAAQ,CAACkC,IAAT,CAAcC;IATvB,CAAD,CAAN,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AD,CAAN,CAGGjB,qBAHH,CAG0B;AAChC;AACA;AACA;AACA;AACA,OARM;MASAP,MAAM,CAAC;QACLQ,SAAS,EAAErC,IAAI,CAAC+B,IAAL,CAAUC,KADhB;QAELM,cAAc,EAAE5C,SAAS,CAACqC,IAAV,CAAeC,KAF1B;QAGLO,aAAa,EAAE1C,QAAQ,CAACkC,IAAT,CAAcC,KAHxB;QAILQ,SAAS,EAAEzC,IAAI,CAACgC,IAAL,CAAUC,KAJhB;QAKLS,QAAQ,EAAEvC,GAAG,CAAC6B,IAAJ,CAASC,KALd;QAMLU,aAAa,EAAEvC,WAAW,CAACC,KAAZ,CAAkB2B,IAAlB,CAAuBC,KANjC;QAOLW,sBAAsB,EAAExC,WAAW,CAACE,cAAZ,CAA2B0B,IAA3B,CAAgCC,KAPnD;QAQLY,QAAQ,EAAEtC,GAAG,CAACyB,IAAJ,CAASC,KAAT,CAAeZ,MAAf,CAAsB,CAAC,CAACyB,IAAD,CAAD,KAAY,CAACA,IAAI,CAACV,QAAL,CAAc,OAAd,CAAnC,CARL;QASLW,YAAY,EAAEhD,OAAO,CAACiC,IAAR,CAAaC;MATtB,CAAD,CAAN,CAUGe,eAVH;IAWD;EACF,CAxDC,CAAF;AAyDD,CAj4BO,CAAR"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { service as _service } from 'knifecycle';
|
|
2
|
-
import { ensureDir as _ensureDir } from 'fs-extra';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import YError from 'yerror';
|
|
5
|
-
const DEFAULT_PROJECT_NAME = 'new-whook-project';
|
|
6
|
-
export default _service(async function initProject({
|
|
7
|
-
CWD,
|
|
8
|
-
lock,
|
|
9
|
-
inquirer,
|
|
10
|
-
ensureDir = _ensureDir,
|
|
11
|
-
log
|
|
12
|
-
}) {
|
|
13
|
-
log('debug', '🏁 - Initializing project...');
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
await lock.take('cli:input');
|
|
17
|
-
const {
|
|
18
|
-
projectName
|
|
19
|
-
} = await inquirer.prompt([{
|
|
20
|
-
name: 'projectName',
|
|
21
|
-
message: "What's this new project name",
|
|
22
|
-
default: DEFAULT_PROJECT_NAME
|
|
23
|
-
}]);
|
|
24
|
-
const {
|
|
25
|
-
projectDirectory
|
|
26
|
-
} = await inquirer.prompt([{
|
|
27
|
-
name: 'projectDirectory',
|
|
28
|
-
message: "Provide the project's directory",
|
|
29
|
-
default: path.join(CWD, projectName)
|
|
30
|
-
}]);
|
|
31
|
-
await lock.release('cli:input');
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
await ensureDir(projectDirectory);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
log('error', `Cannot create the project's directory: "${projectDirectory}"`);
|
|
37
|
-
log('error-stack', err.stack || 'no_stack_trace');
|
|
38
|
-
throw YError.wrap(err, 'E_PROJECT_DIR', projectDirectory);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
name: projectName,
|
|
43
|
-
directory: projectDirectory
|
|
44
|
-
};
|
|
45
|
-
} catch (err) {
|
|
46
|
-
await lock.release('cli:input');
|
|
47
|
-
throw YError.cast(err);
|
|
48
|
-
}
|
|
49
|
-
}, "project", ["CWD", "lock", "inquirer", "?ensureDir", "log"]);
|
|
50
|
-
//# sourceMappingURL=project.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project.mjs","names":["autoService","ensureDir","_ensureDir","path","YError","DEFAULT_PROJECT_NAME","initProject","CWD","lock","inquirer","log","take","projectName","prompt","name","message","default","projectDirectory","join","release","err","stack","wrap","directory","cast"],"sources":["../../src/services/project.ts"],"sourcesContent":["import { autoService } from 'knifecycle';\nimport { ensureDir as _ensureDir } from 'fs-extra';\nimport path from 'path';\nimport _inquirer from 'inquirer';\nimport YError from 'yerror';\nimport type { LockService, LogService } from 'common-services';\n\nconst DEFAULT_PROJECT_NAME = 'new-whook-project';\n\nexport interface ProjectService {\n name: string;\n directory: string;\n}\n\nexport default autoService(async function initProject({\n CWD,\n lock,\n inquirer,\n ensureDir = _ensureDir,\n log,\n}: {\n CWD: string;\n lock: LockService<string>;\n inquirer: typeof _inquirer;\n ensureDir: typeof _ensureDir;\n log: LogService;\n}): Promise<ProjectService> {\n log('debug', '🏁 - Initializing project...');\n try {\n await lock.take('cli:input');\n\n const { projectName } = await inquirer.prompt([\n {\n name: 'projectName',\n message: \"What's this new project name\",\n default: DEFAULT_PROJECT_NAME,\n },\n ]);\n\n const { projectDirectory } = await inquirer.prompt([\n {\n name: 'projectDirectory',\n message: \"Provide the project's directory\",\n default: path.join(CWD, projectName),\n },\n ]);\n await lock.release('cli:input');\n\n try {\n await ensureDir(projectDirectory);\n } catch (err) {\n log(\n 'error',\n `Cannot create the project's directory: \"${projectDirectory}\"`,\n );\n log('error-stack', (err as Error).stack || 'no_stack_trace');\n throw YError.wrap(err as Error, 'E_PROJECT_DIR', projectDirectory);\n }\n\n return {\n name: projectName,\n directory: projectDirectory,\n };\n } catch (err) {\n await lock.release('cli:input');\n throw YError.cast(err as Error);\n }\n});\n"],"mappings":"AAAA,SAASA,OAAW,IAAXA,QAAT,QAA4B,YAA5B;AACA,SAASC,SAAS,IAAIC,UAAtB,QAAwC,UAAxC;AACA,OAAOC,IAAP,MAAiB,MAAjB;AAEA,OAAOC,MAAP,MAAmB,QAAnB;AAGA,MAAMC,oBAAoB,GAAG,mBAA7B;AAOA,eAAeL,QAAW,CAAC,eAAeM,WAAf,CAA2B;EACpDC,GADoD;EAEpDC,IAFoD;EAGpDC,QAHoD;EAIpDR,SAAS,GAAGC,UAJwC;EAKpDQ;AALoD,CAA3B,EAYC;EAC1BA,GAAG,CAAC,OAAD,EAAU,8BAAV,CAAH;;EACA,IAAI;IACF,MAAMF,IAAI,CAACG,IAAL,CAAU,WAAV,CAAN;IAEA,MAAM;MAAEC;IAAF,IAAkB,MAAMH,QAAQ,CAACI,MAAT,CAAgB,CAC5C;MACEC,IAAI,EAAE,aADR;MAEEC,OAAO,EAAE,8BAFX;MAGEC,OAAO,EAAEX;IAHX,CAD4C,CAAhB,CAA9B;IAQA,MAAM;MAAEY;IAAF,IAAuB,MAAMR,QAAQ,CAACI,MAAT,CAAgB,CACjD;MACEC,IAAI,EAAE,kBADR;MAEEC,OAAO,EAAE,iCAFX;MAGEC,OAAO,EAAEb,IAAI,CAACe,IAAL,CAAUX,GAAV,EAAeK,WAAf;IAHX,CADiD,CAAhB,CAAnC;IAOA,MAAMJ,IAAI,CAACW,OAAL,CAAa,WAAb,CAAN;;IAEA,IAAI;MACF,MAAMlB,SAAS,CAACgB,gBAAD,CAAf;IACD,CAFD,CAEE,OAAOG,GAAP,EAAY;MACZV,GAAG,CACD,OADC,EAEA,2CAA0CO,gBAAiB,GAF3D,CAAH;MAIAP,GAAG,CAAC,aAAD,EAAiBU,GAAD,CAAeC,KAAf,IAAwB,gBAAxC,CAAH;MACA,MAAMjB,MAAM,CAACkB,IAAP,CAAYF,GAAZ,EAA0B,eAA1B,EAA2CH,gBAA3C,CAAN;IACD;;IAED,OAAO;MACLH,IAAI,EAAEF,WADD;MAELW,SAAS,EAAEN;IAFN,CAAP;EAID,CAnCD,CAmCE,OAAOG,GAAP,EAAY;IACZ,MAAMZ,IAAI,CAACW,OAAL,CAAa,WAAb,CAAN;IACA,MAAMf,MAAM,CAACoB,IAAP,CAAYJ,GAAZ,CAAN;EACD;AACF,CArDyB,8DAA1B"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import initProject from './project';
|
|
2
|
-
import YError from 'yerror';
|
|
3
|
-
describe('initProject', () => {
|
|
4
|
-
const CWD = '/home/whoiam/projects/';
|
|
5
|
-
const inquirer = {
|
|
6
|
-
prompt: jest.fn()
|
|
7
|
-
};
|
|
8
|
-
const lock = {
|
|
9
|
-
take: jest.fn(),
|
|
10
|
-
release: jest.fn()
|
|
11
|
-
};
|
|
12
|
-
const ensureDir = jest.fn();
|
|
13
|
-
const log = jest.fn();
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
lock.take.mockReset();
|
|
16
|
-
inquirer.prompt.mockReset();
|
|
17
|
-
lock.release.mockReset();
|
|
18
|
-
ensureDir.mockReset();
|
|
19
|
-
log.mockReset();
|
|
20
|
-
});
|
|
21
|
-
it('should work', async () => {
|
|
22
|
-
lock.take.mockResolvedValueOnce(undefined);
|
|
23
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
24
|
-
projectName: 'super-project'
|
|
25
|
-
});
|
|
26
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
27
|
-
projectDirectory: '/home/whoiam/projects/yolo'
|
|
28
|
-
});
|
|
29
|
-
lock.release.mockResolvedValueOnce(undefined);
|
|
30
|
-
ensureDir.mockResolvedValueOnce(undefined);
|
|
31
|
-
const project = await initProject({
|
|
32
|
-
inquirer: inquirer,
|
|
33
|
-
CWD,
|
|
34
|
-
ensureDir,
|
|
35
|
-
lock,
|
|
36
|
-
log
|
|
37
|
-
});
|
|
38
|
-
expect({
|
|
39
|
-
project,
|
|
40
|
-
inquirerPromptCalls: inquirer.prompt.mock.calls,
|
|
41
|
-
lockTakeCalls: lock.take.mock.calls,
|
|
42
|
-
lockReleaseCalls: lock.release.mock.calls,
|
|
43
|
-
ensureDirCalls: ensureDir.mock.calls,
|
|
44
|
-
logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack'))
|
|
45
|
-
}).toMatchSnapshot();
|
|
46
|
-
});
|
|
47
|
-
it('should fail with access problems', async () => {
|
|
48
|
-
lock.take.mockResolvedValueOnce(undefined);
|
|
49
|
-
lock.release.mockResolvedValueOnce(undefined);
|
|
50
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
51
|
-
projectName: 'super-project'
|
|
52
|
-
});
|
|
53
|
-
inquirer.prompt.mockResolvedValueOnce({
|
|
54
|
-
projectDirectory: '/home/whoiam/projects/yolo'
|
|
55
|
-
});
|
|
56
|
-
ensureDir.mockRejectedValueOnce(new YError('E_ACCESS'));
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
await initProject({
|
|
60
|
-
inquirer: inquirer,
|
|
61
|
-
CWD,
|
|
62
|
-
ensureDir,
|
|
63
|
-
lock,
|
|
64
|
-
log
|
|
65
|
-
});
|
|
66
|
-
throw new YError('E_UNEXPECTED_SUCCESS');
|
|
67
|
-
} catch (err) {
|
|
68
|
-
expect({
|
|
69
|
-
errorCode: err.code,
|
|
70
|
-
errorParams: err.params,
|
|
71
|
-
inquirerPromptCalls: inquirer.prompt.mock.calls,
|
|
72
|
-
lockTakeCalls: lock.take.mock.calls,
|
|
73
|
-
lockReleaseCalls: lock.release.mock.calls,
|
|
74
|
-
ensureDirCalls: ensureDir.mock.calls,
|
|
75
|
-
logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack'))
|
|
76
|
-
}).toMatchSnapshot();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=project.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project.test.mjs","names":["initProject","YError","describe","CWD","inquirer","prompt","jest","fn","lock","take","release","ensureDir","log","beforeEach","mockReset","it","mockResolvedValueOnce","undefined","projectName","projectDirectory","project","expect","inquirerPromptCalls","mock","calls","lockTakeCalls","lockReleaseCalls","ensureDirCalls","logCalls","filter","type","endsWith","toMatchSnapshot","mockRejectedValueOnce","err","errorCode","code","errorParams","params"],"sources":["../../src/services/project.test.ts"],"sourcesContent":["import _inquirer from 'inquirer';\nimport initProject from './project';\nimport YError from 'yerror';\n\ndescribe('initProject', () => {\n const CWD = '/home/whoiam/projects/';\n const inquirer = { prompt: jest.fn() };\n const lock = { take: jest.fn(), release: jest.fn() };\n const ensureDir = jest.fn();\n const log = jest.fn();\n\n beforeEach(() => {\n lock.take.mockReset();\n inquirer.prompt.mockReset();\n lock.release.mockReset();\n ensureDir.mockReset();\n log.mockReset();\n });\n\n it('should work', async () => {\n lock.take.mockResolvedValueOnce(undefined);\n inquirer.prompt.mockResolvedValueOnce({\n projectName: 'super-project',\n });\n inquirer.prompt.mockResolvedValueOnce({\n projectDirectory: '/home/whoiam/projects/yolo',\n });\n lock.release.mockResolvedValueOnce(undefined);\n ensureDir.mockResolvedValueOnce(undefined);\n\n const project = await initProject({\n inquirer: inquirer as unknown as typeof _inquirer,\n CWD,\n ensureDir,\n lock,\n log,\n });\n\n expect({\n project,\n inquirerPromptCalls: inquirer.prompt.mock.calls,\n lockTakeCalls: lock.take.mock.calls,\n lockReleaseCalls: lock.release.mock.calls,\n ensureDirCalls: ensureDir.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n }).toMatchSnapshot();\n });\n\n it('should fail with access problems', async () => {\n lock.take.mockResolvedValueOnce(undefined);\n lock.release.mockResolvedValueOnce(undefined);\n inquirer.prompt.mockResolvedValueOnce({\n projectName: 'super-project',\n });\n inquirer.prompt.mockResolvedValueOnce({\n projectDirectory: '/home/whoiam/projects/yolo',\n });\n ensureDir.mockRejectedValueOnce(new YError('E_ACCESS'));\n\n try {\n await initProject({\n inquirer: inquirer as unknown as typeof _inquirer,\n CWD,\n ensureDir,\n lock,\n log,\n });\n throw new YError('E_UNEXPECTED_SUCCESS');\n } catch (err) {\n expect({\n errorCode: (err as YError).code,\n errorParams: (err as YError).params,\n inquirerPromptCalls: inquirer.prompt.mock.calls,\n lockTakeCalls: lock.take.mock.calls,\n lockReleaseCalls: lock.release.mock.calls,\n ensureDirCalls: ensureDir.mock.calls,\n logCalls: log.mock.calls.filter(([type]) => !type.endsWith('stack')),\n }).toMatchSnapshot();\n }\n });\n});\n"],"mappings":"AACA,OAAOA,WAAP,MAAwB,WAAxB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AAEAC,QAAQ,CAAC,aAAD,EAAgB,MAAM;EAC5B,MAAMC,GAAG,GAAG,wBAAZ;EACA,MAAMC,QAAQ,GAAG;IAAEC,MAAM,EAAEC,IAAI,CAACC,EAAL;EAAV,CAAjB;EACA,MAAMC,IAAI,G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