diff --git a/packages/okam-cli/bin/okam-init b/packages/okam-cli/bin/okam-init index 1f5c9f78..3b17adda 100755 --- a/packages/okam-cli/bin/okam-init +++ b/packages/okam-cli/bin/okam-init @@ -8,7 +8,8 @@ program const args = program.args const project = new Project({ - dirName: args[0] + dirName: args[0], + pkgName: args[1] }); project.create(); diff --git a/packages/okam-cli/package-lock.json b/packages/okam-cli/package-lock.json index b1424745..d13a03b6 100644 --- a/packages/okam-cli/package-lock.json +++ b/packages/okam-cli/package-lock.json @@ -1,6 +1,6 @@ { "name": "okam-cli", - "version": "0.1.5", + "version": "0.1.10", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -27,6 +27,68 @@ "color-convert": "^1.9.0" } }, + "archive-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/archive-type/-/archive-type-4.0.0.tgz", + "integrity": "sha1-+S5yIzBW38aWlHJ0nCZ72wRrHXA=", + "requires": { + "file-type": "^4.2.0" + }, + "dependencies": { + "file-type": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-4.4.0.tgz", + "integrity": "sha1-G2AOX8ofvcboDApwxxyNul95BsU=" + } + } + }, + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "bl": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==" + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" + }, "cacheable-request": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-2.1.4.tgz", @@ -48,6 +110,17 @@ } } }, + "caw": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/caw/-/caw-2.0.1.tgz", + "integrity": "sha512-Cg8/ZSBEa8ZVY9HspcGUYaK63d/bN7rqS3CYCzEGUxuYv6UlmcjzDUz2fCFFHyTvUW5Pk0I+3hkA3iXlIj6guA==", + "requires": { + "get-proxy": "^2.0.0", + "isurl": "^1.0.0-alpha5", + "tunnel-agent": "^0.6.0", + "url-to-options": "^1.0.1" + } + }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -112,6 +185,23 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" }, + "config-chain": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz", + "integrity": "sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==", + "requires": { + "ini": "^1.3.4", + "proto-list": "~1.2.1" + } + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -122,6 +212,28 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, + "decompress": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.0.tgz", + "integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=", + "requires": { + "decompress-tar": "^4.0.0", + "decompress-tarbz2": "^4.0.0", + "decompress-targz": "^4.0.0", + "decompress-unzip": "^4.0.1", + "graceful-fs": "^4.1.10", + "make-dir": "^1.0.0", + "pify": "^2.3.0", + "strip-dirs": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } + } + }, "decompress-response": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", @@ -130,6 +242,91 @@ "mimic-response": "^1.0.0" } }, + "decompress-tar": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", + "requires": { + "file-type": "^5.2.0", + "is-stream": "^1.1.0", + "tar-stream": "^1.5.2" + }, + "dependencies": { + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=" + } + } + }, + "decompress-tarbz2": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", + "requires": { + "decompress-tar": "^4.1.0", + "file-type": "^6.1.0", + "is-stream": "^1.1.0", + "seek-bzip": "^1.0.5", + "unbzip2-stream": "^1.0.9" + }, + "dependencies": { + "file-type": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==" + } + } + }, + "decompress-targz": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", + "requires": { + "decompress-tar": "^4.1.1", + "file-type": "^5.2.0", + "is-stream": "^1.1.0" + }, + "dependencies": { + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=" + } + } + }, + "decompress-unzip": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz", + "integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=", + "requires": { + "file-type": "^3.8.0", + "get-stream": "^2.2.0", + "pify": "^2.3.0", + "yauzl": "^2.4.2" + }, + "dependencies": { + "file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" + }, + "get-stream": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", + "integrity": "sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=", + "requires": { + "object-assign": "^4.0.1", + "pinkie-promise": "^2.0.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + } + } + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", @@ -143,11 +340,38 @@ "clone": "^1.0.2" } }, + "download": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz", + "integrity": "sha512-xqnBTVd/E+GxJVrX5/eUJiLYjCGPwMpdL+jGhGU57BvtcA7wwhtHVbXBeUk51kOpW3S7Jn3BQbN9Q1R1Km2qDQ==", + "requires": { + "archive-type": "^4.0.0", + "caw": "^2.0.1", + "content-disposition": "^0.5.2", + "decompress": "^4.2.0", + "ext-name": "^5.0.0", + "file-type": "^8.1.0", + "filenamify": "^2.0.0", + "get-stream": "^3.0.0", + "got": "^8.3.1", + "make-dir": "^1.2.0", + "p-event": "^2.1.0", + "pify": "^3.0.0" + } + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "requires": { + "once": "^1.4.0" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -158,6 +382,23 @@ "resolved": "https://registry.npmjs.org/etpl/-/etpl-3.2.0.tgz", "integrity": "sha1-6yCEfQjqsCzbA6eAz3a3V1kzFhs=" }, + "ext-list": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/ext-list/-/ext-list-2.2.2.tgz", + "integrity": "sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==", + "requires": { + "mime-db": "^1.28.0" + } + }, + "ext-name": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ext-name/-/ext-name-5.0.0.tgz", + "integrity": "sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==", + "requires": { + "ext-list": "^2.0.0", + "sort-keys-length": "^1.0.0" + } + }, "external-editor": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", @@ -168,6 +409,14 @@ "tmp": "^0.0.33" } }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "requires": { + "pend": "~1.2.0" + } + }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -176,6 +425,26 @@ "escape-string-regexp": "^1.0.5" } }, + "file-type": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-8.1.0.tgz", + "integrity": "sha512-qyQ0pzAy78gVoJsmYeNgl8uH8yKhr1lVhW7JbzJmnlRi0I4R2eEDEJZVKG8agpDnLpacwNbDhLNG/LMdxHD2YQ==" + }, + "filename-reserved-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz", + "integrity": "sha1-q/c9+rc10EVECr/qLZHzieu/oik=" + }, + "filenamify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-2.1.0.tgz", + "integrity": "sha512-ICw7NTT6RsDp2rnYKVd8Fu4cr6ITzGy3+u4vUujPkabyaz+03F24NWEX7fs5fp+kBonlaqPH8fAO2NM+SXt/JA==", + "requires": { + "filename-reserved-regex": "^2.0.0", + "strip-outer": "^1.0.0", + "trim-repeated": "^1.0.0" + } + }, "from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -185,6 +454,11 @@ "readable-stream": "^2.0.0" } }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -195,9 +469,17 @@ "universalify": "^0.1.0" } }, + "get-proxy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/get-proxy/-/get-proxy-2.1.0.tgz", + "integrity": "sha512-zmZIaQTWnNQb4R4fJUEp/FC51eZsc6EkErspy3xtIYStaq8EB/hDIWipxsal+E8rz0qD7f2sL/NA9Xee4RInJw==", + "requires": { + "npm-conf": "^1.1.0" + } + }, "get-stream": { "version": "3.0.0", - "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "got": { @@ -229,6 +511,11 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -260,6 +547,11 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ieee754": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==" + }, "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", @@ -292,7 +584,7 @@ }, "into-stream": { "version": "3.1.0", - "resolved": "http://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", + "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", "requires": { "from2": "^2.1.1", @@ -304,6 +596,11 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" }, + "is-natural-number": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", + "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=" + }, "is-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", @@ -324,6 +621,11 @@ "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=" }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -385,6 +687,19 @@ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==" }, + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "requires": { + "pify": "^3.0.0" + } + }, + "mime-db": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", + "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + }, "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", @@ -430,11 +745,28 @@ "sort-keys": "^2.0.0" } }, + "npm-conf": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/npm-conf/-/npm-conf-1.1.3.tgz", + "integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==", + "requires": { + "config-chain": "^1.1.11", + "pify": "^3.0.0" + } + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, "onetime": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", @@ -476,6 +808,14 @@ "resolved": "http://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.1.tgz", "integrity": "sha512-HNa1A8LvB1kie7cERyy21VNeHb2CWJJYqyyC2o3klWFfMGlFmWv2Z7sFgZH8ZiaYL95ydToKTFVXgMV/Os0bBQ==" }, + "p-event": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/p-event/-/p-event-2.3.1.tgz", + "integrity": "sha512-NQCqOFhbpVTMX4qMe8PF8lbGtzZ+LCiN7pcNrb/413Na7+TRoe1xkKUzuWa/YEJdGQ0FvKtj35EEbDoVPO2kbA==", + "requires": { + "p-timeout": "^2.0.1" + } + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -505,11 +845,29 @@ "semver": "^5.5.0" } }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, "prepend-http": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", @@ -520,6 +878,11 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, + "proto-list": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", + "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=" + }, "query-string": { "version": "5.1.1", "resolved": "http://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", @@ -615,6 +978,24 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "seek-bzip": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz", + "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", + "requires": { + "commander": "~2.8.1" + }, + "dependencies": { + "commander": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", + "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", + "requires": { + "graceful-readlink": ">= 1.0.0" + } + } + } + }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", @@ -633,6 +1014,24 @@ "is-plain-obj": "^1.0.0" } }, + "sort-keys-length": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sort-keys-length/-/sort-keys-length-1.0.1.tgz", + "integrity": "sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=", + "requires": { + "sort-keys": "^1.0.0" + }, + "dependencies": { + "sort-keys": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", + "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", + "requires": { + "is-plain-obj": "^1.0.0" + } + } + } + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -680,11 +1079,27 @@ } } }, + "strip-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", + "requires": { + "is-natural-number": "^4.0.1" + } + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, + "strip-outer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", + "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -693,6 +1108,20 @@ "has-flag": "^3.0.0" } }, + "tar-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.6.2.tgz", + "integrity": "sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==", + "requires": { + "bl": "^1.0.0", + "buffer-alloc": "^1.2.0", + "end-of-stream": "^1.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.1", + "xtend": "^4.0.0" + } + }, "through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -711,11 +1140,41 @@ "os-tmpdir": "~1.0.2" } }, + "to-buffer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", + "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==" + }, + "trim-repeated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", + "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "unbzip2-stream": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", + "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -746,6 +1205,25 @@ "requires": { "defaults": "^1.0.3" } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } } } } diff --git a/packages/okam-cli/package.json b/packages/okam-cli/package.json index d69f62e2..00551e9b 100644 --- a/packages/okam-cli/package.json +++ b/packages/okam-cli/package.json @@ -4,6 +4,7 @@ "description": "The cli tool for Okam develop framework", "main": "index.js", "scripts": { + "lint": "fecs ./src index.js --reporter=baidu --rule", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -30,6 +31,7 @@ "dependencies": { "chalk": "^2.4.1", "commander": "^2.19.0", + "download": "^7.1.0", "etpl": "^3.2.0", "fs-extra": "^7.0.1", "inquirer": "^6.2.0", diff --git a/packages/okam-cli/src/Project.js b/packages/okam-cli/src/Project.js index 0379a34b..84234227 100644 --- a/packages/okam-cli/src/Project.js +++ b/packages/okam-cli/src/Project.js @@ -10,9 +10,11 @@ const semver = require('semver'); const execSync = require('child_process').execSync; const ora = require('ora'); const Etpl = require('./utils/etpl'); -const isEmptyDir = require('./utils').isEmptyDir; +const {isEmptyDir, validateDir} = require('./utils'); const BaseTemplate = require('../templates/index'); +const OnlineTemplate = require('../templates/onlineTemplate'); const {promptUpdateCli, promptList, setPromptsValue} = require('./utils/prompts'); +const {downloadOfficialZip} = require('./download'); class Project { constructor(options) { @@ -78,6 +80,45 @@ class Project { console.log(chalk.green('Create a new okam project')); + const config = this.conf; + + // isOfficialZip + if (/@okam\/.*/.test(config.dirName || '')) { + + let rs = validateDir(config.pkgName); + + // 这里的返回值是 string / boolean =.= + if (rs !== true) { + console.log(chalk.red(rs)); + return; + } + + const spinner = ora(`download template ${config.dirName}`).start(); + let remoteDirName = config.dirName.replace('@okam/', ''); + + // use official template + downloadOfficialZip( + remoteDirName, + config.pkgName, + { + extract: true + } + ).then(() => { + spinner.stop(); + + new OnlineTemplate(this, this.conf, {}); + }).catch(e => { + spinner.stop(); + if (e.statusCode === 404) { + console.log(chalk.red(`Unrecongnized template: '${remoteDirName}'.`)); + } + else if (e) { + console.log(chalk.red(`Failed to download repo ${remoteDirName}: ${e.message.trim()}`)); + } + }); + return; + } + this.ask().then(answers => { const date = new Date(); this.conf = Object.assign(this.conf, answers); @@ -94,7 +135,7 @@ class Project { if (dirName && fs.existsSync(dirName) && (!isEmptyDir(dirName))) { this.conf.dirName = ''; setPromptsValue(prompts, 'projectName', { - message: 'The target directory is existed, change another name:' + message: 'The target directory is existed, please change another name:' }); } else if (dirName) { diff --git a/packages/okam-cli/src/download.js b/packages/okam-cli/src/download.js new file mode 100644 index 00000000..e79093d2 --- /dev/null +++ b/packages/okam-cli/src/download.js @@ -0,0 +1,25 @@ +/** + * @file download.js + * @author xiaohong8023@outlook.com + * + * templates: https://github.com/awesome-okam/okam-online-templates/tree/master/templates + */ + +const download = require('download'); + +const zipsDir = 'https://raw.githubusercontent.com/awesome-okam/okam-online-templates/master/zips'; + +module.exports = { + + /** + * download official template zip + * + * @param {string} templateName templateName + * @param {string} dist dist + * @param {Object} options options + * @return {Object} + */ + downloadOfficialZip(templateName, dist, options) { + return download(`${zipsDir}/${templateName}.zip`, dist, options); + } +}; diff --git a/packages/okam-cli/src/utils/index.js b/packages/okam-cli/src/utils/index.js index 10be98b9..0ee6281c 100644 --- a/packages/okam-cli/src/utils/index.js +++ b/packages/okam-cli/src/utils/index.js @@ -6,6 +6,7 @@ const execSync = require('child_process').execSync; const os = require('os'); const fs = require('fs-extra'); +const path = require('path'); /** * 获取系统用户名 @@ -55,9 +56,84 @@ function isEmptyDir(currDir) { return !files.length; } +/** + * 有效文件夹 + * + * @param {string} currDir currDir + * @return {boolean} + */ +function validateDir(currDir) { + if (!currDir) { + return 'The project name can not be empty!'; + } + + if (fs.existsSync(currDir) && (!isEmptyDir(currDir))) { + return 'The target directory is existed, please change another name!'; + } + + return true; +} + +/** + * 获取给定的文件路径的状态信息 + * + * @inner + * @param {string} target 文件的目标路径 + * @return {?Object} + */ +function getFileState(target) { + try { + let state = fs.statSync(target); + return state; + } + catch (ex) { + // ignore + } +} + +/** + * 遍历当前文件夹下的文件并进行回调操作 + * + * @param {string} curDir 当前的目录 + * @param {Function} cb callback function + */ +function traverseFilesAndCb(curDir, cb) { + let fileDirs = [curDir]; + while (fileDirs.length) { + let currDir = fileDirs.pop(); + let files = fs.readdirSync(currDir); + for (let i = 0, len = files.length; i < len; i++) { + let fileName = files[i]; + + if (/^\./.test(fileName)) { + continue; + } + + let fullPath = path.resolve(currDir, fileName); + let stat = getFileState(fullPath); + if (!stat) { + continue; + } + + let isDir = stat.isDirectory(); + if (isDir) { + fileDirs.push(fullPath); + continue; + } + + if (typeof cb === 'function') { + cb(fullPath); + } + } + } +} + module.exports = { getSystemUserName, getGitUser, + getAuthor, isEmptyDir, - getAuthor + validateDir, + getFileState, + traverseFilesAndCb }; diff --git a/packages/okam-cli/src/utils/prompts.js b/packages/okam-cli/src/utils/prompts.js index 3880fee0..0bc35cca 100644 --- a/packages/okam-cli/src/utils/prompts.js +++ b/packages/okam-cli/src/utils/prompts.js @@ -3,8 +3,7 @@ * @author xiaohong8023@outlook.com */ -const fs = require('fs-extra'); -const {getAuthor, isEmptyDir} = require('./index'); +const {getAuthor, validateDir} = require('./index'); function setPromptsValue(prompts, name, options) { let promptsLen = prompts.length; @@ -22,15 +21,7 @@ let promptList = [ 'name': 'projectName', 'message': 'Project name:', /* eslint-disable fecs-use-method-definition */ - 'validate': function (input) { - if (!input) { - return 'The project name can not be empty!'; - } - if (fs.existsSync(input) && (!isEmptyDir(input))) { - return 'The target directory is existed, please change another name!'; - } - return true; - } + 'validate': validateDir }, { 'type': 'input', diff --git a/packages/okam-cli/templates/base/README.md b/packages/okam-cli/templates/base/README.md index c883d92a..61979ca3 100644 --- a/packages/okam-cli/templates/base/README.md +++ b/packages/okam-cli/templates/base/README.md @@ -27,9 +27,7 @@ ${description} * `npm run dev:server`: 带 watch && 开发 Server 开发模式 - * `npm run build`: 删掉构建重新构建(没有 watch && 开发 Server) - - * `npm run prod`: 生产环境构建 + * `npm run prod`: 生产环境构建(没有 watch && 开发 Server) * 微信小程序运行命令 @@ -39,7 +37,7 @@ ${description} * `npm run dev:wx:server`: 带 watch && 开发 Server 开发模式 - * `npm run prod:wx`: 微信小程序生产环境构建 + * `npm run prod:wx`: 微信小程序生产环境构建(没有 watch && 开发 Server) * 支付宝小程序运行命令 @@ -49,7 +47,7 @@ ${description} * `npm run dev:ant:server`:带 watch && 开发 Server 开发模式 - * `npm run prod:ant`: 微信小程序生产环境构建 + * `npm run prod:ant`: 微信小程序生产环境构建(没有 watch && 开发 Server) * 头条小程序运行命令 @@ -59,7 +57,7 @@ ${description} * `npm run dev:tt:server`:带 watch && 开发 Server 开发模式 - * `npm run prod:tt`: 微信小程序生产环境构建 + * `npm run prod:tt`: 微信小程序生产环境构建(没有 watch && 开发 Server) * 快应用小程序运行命令 @@ -70,7 +68,7 @@ ${description} * `npm run dev:quick:server`:带 watch && 开发 Server 开发模式 - * `npm run prod:quick`: 快应用小程序生产环境构建 + * `npm run prod:quick`: 快应用小程序生产环境构建(没有 watch && 开发 Server) ### 注意 diff --git a/packages/okam-cli/templates/index.js b/packages/okam-cli/templates/index.js index daabd18a..90bd3338 100644 --- a/packages/okam-cli/templates/index.js +++ b/packages/okam-cli/templates/index.js @@ -8,23 +8,7 @@ const path = require('path'); const getLatestVersion = require('latest-version'); const chalk = require('chalk'); const ora = require('ora'); - -/** - * 获取给定的文件路径的状态信息 - * - * @inner - * @param {string} target 文件的目标路径 - * @return {?Object} - */ -function getFileState(target) { - try { - let state = fs.statSync(target); - return state; - } - catch (ex) { - // ignore - } -} +const {traverseFilesAndCb} = require('../src/utils'); /** * script extname @@ -271,26 +255,26 @@ class BaseTemplate { const spinner = ora('Creating the project, please wait a moment...').start(); // scripts/ files - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'scripts'), this.generateBuild.bind(this) ); // src/ files - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'src'), this.generateNormalFiles.bind(this) ); // . files - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'dotFilesAll'), this.generateDotFilesAll.bind(this) ); // redux if (this.params.redux) { - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'reduxSrc'), this.generateReduxFiles.bind(this) ); @@ -298,7 +282,7 @@ class BaseTemplate { // fecs if (this.params.lint === 'fecs') { - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'dotFilesFecs'), this.generateDotFilesFecs.bind(this) ); @@ -306,7 +290,7 @@ class BaseTemplate { // eslint if (this.params.lint === 'eslint') { - this.traverseFilesAndCb( + traverseFilesAndCb( path.join(this.templatePath, 'dotFilesESLint'), this.generateDotFilesESLint.bind(this) ); @@ -527,43 +511,6 @@ class BaseTemplate { this.params ); } - - /** - * 遍历当前文件夹下的文件并进行回调操作 - * - * @param {string} curDir 当前的目录 - * @param {Function} cb callback function - */ - traverseFilesAndCb(curDir, cb) { - let fileDirs = [curDir]; - while (fileDirs.length) { - let currDir = fileDirs.pop(); - let files = fs.readdirSync(currDir); - for (let i = 0, len = files.length; i < len; i++) { - let fileName = files[i]; - - if (/^\./.test(fileName)) { - continue; - } - - let fullPath = path.resolve(currDir, fileName); - let stat = getFileState(fullPath); - if (!stat) { - continue; - } - - let isDir = stat.isDirectory(); - if (isDir) { - fileDirs.push(fullPath); - continue; - } - - if (typeof cb === 'function') { - cb(fullPath); - } - } - } - } } module.exports = BaseTemplate; diff --git a/packages/okam-cli/templates/onlineTemplate.js b/packages/okam-cli/templates/onlineTemplate.js new file mode 100644 index 00000000..fcbd57fb --- /dev/null +++ b/packages/okam-cli/templates/onlineTemplate.js @@ -0,0 +1,61 @@ +/** + * @file online template hanlder + * @author xiaohong8023@outlook.com + * + * + */ + +const path = require('path'); +const chalk = require('chalk'); +const ora = require('ora'); + +class OnlineTemplate { + constructor(creater, params, helper, cb) { + this.creater = creater; + this.params = params; + this.helper = helper; + + // current project path + this.projectPath = path.join(process.cwd(), this.params.pkgName); + + this.templatePath = this.projectPath; + + // start create project + this.create(); + + if (typeof cb === 'function') { + cb(); + } + } + + async create() { + const spinner = ora('Creating the project, please wait a moment...').start(); + + // 当前仅处理了两个文件 + const renderFiles = ['package.json', 'README.md']; + + renderFiles.forEach(fileName => { + this.creater.etplEngine.renderTplToFile( + path.join(this.templatePath, fileName), + path.join(this.projectPath, fileName), + this.params + ); + }); + + spinner.stop(); + this.endGuide(); + } + + /** + * end guide + */ + endGuide() { + console.log(chalk.green('The project was created successfully!')); + console.log('# prepare'); + console.log(` cd ${this.params.pkgName} && npm i`); + console.log('# start'); + console.log(' see README.md'); + } +} + +module.exports = OnlineTemplate;