diff --git a/package.json b/package.json index ffedd06..205a4df 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,35 @@ { "name": "ttpg-scripts", - "version": "1.1.0", + "version": "1.3.0", "description": "", "bin": { "ttpg-scripts": "./bin/index.js" }, "scripts": { "build": "tsc", - "clean": "rm -rf ./bin/" + "clean": "rm -rf ./bin/", + "test": "rollup -h" }, "keywords": [], "author": "", "license": "UNLICENSE", "devDependencies": { - "@types/node": "^20.4.8", - "@types/uuid": "^9.0.2", "@types/archiver": "^5.3.2", - "@types/cross-spawn": "^6.0.2" + "@types/cross-spawn": "^6.0.2", + "@types/node": "^20.4.8", + "@types/uuid": "^9.0.2" }, "dependencies": { - "typescript": "^5.1.6", + "@rollup/plugin-commonjs": "^25.0.3", + "@rollup/plugin-node-resolve": "^15.1.0", + "@rollup/plugin-terser": "^0.4.3", + "archiver": "^5.3.1", + "chokidar": "^3.5.3", "colorette": "^2.0.20", "cross-spawn": "^7.0.3", - "uuid": "^9.0.0", - "archiver": "^5.3.1" + "fast-glob": "^3.3.1", + "rollup": "^3.28.0", + "typescript": "^5.1.6", + "uuid": "^9.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dde0190..6aa705f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,15 +5,33 @@ settings: excludeLinksFromLockfile: false dependencies: + '@rollup/plugin-commonjs': + specifier: ^25.0.3 + version: 25.0.3(rollup@3.28.0) + '@rollup/plugin-node-resolve': + specifier: ^15.1.0 + version: 15.1.0(rollup@3.28.0) + '@rollup/plugin-terser': + specifier: ^0.4.3 + version: 0.4.3(rollup@3.28.0) archiver: specifier: ^5.3.1 version: 5.3.1 + chokidar: + specifier: ^3.5.3 + version: 3.5.3 colorette: specifier: ^2.0.20 version: 2.0.20 cross-spawn: specifier: ^7.0.3 version: 7.0.3 + fast-glob: + specifier: ^3.3.1 + version: 3.3.1 + rollup: + specifier: ^3.28.0 + version: 3.28.0 typescript: specifier: ^5.1.6 version: 5.1.6 @@ -37,6 +55,130 @@ devDependencies: packages: + /@jridgewell/gen-mapping@0.3.3: + resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} + engines: {node: '>=6.0.0'} + dependencies: + '@jridgewell/set-array': 1.1.2 + '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/trace-mapping': 0.3.19 + dev: false + + /@jridgewell/resolve-uri@3.1.1: + resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} + engines: {node: '>=6.0.0'} + dev: false + + /@jridgewell/set-array@1.1.2: + resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} + engines: {node: '>=6.0.0'} + dev: false + + /@jridgewell/source-map@0.3.5: + resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==} + dependencies: + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.19 + dev: false + + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: false + + /@jridgewell/trace-mapping@0.3.19: + resolution: {integrity: sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==} + dependencies: + '@jridgewell/resolve-uri': 3.1.1 + '@jridgewell/sourcemap-codec': 1.4.15 + dev: false + + /@nodelib/fs.scandir@2.1.5: + resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + run-parallel: 1.2.0 + dev: false + + /@nodelib/fs.stat@2.0.5: + resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} + engines: {node: '>= 8'} + dev: false + + /@nodelib/fs.walk@1.2.8: + resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} + engines: {node: '>= 8'} + dependencies: + '@nodelib/fs.scandir': 2.1.5 + fastq: 1.15.0 + dev: false + + /@rollup/plugin-commonjs@25.0.3(rollup@3.28.0): + resolution: {integrity: sha512-uBdtWr/H3BVcgm97MUdq2oJmqBR23ny1hOrWe2PKo9FTbjsGqg32jfasJUKYAI5ouqacjRnj65mBB/S79F+GQA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.68.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.0.2(rollup@3.28.0) + commondir: 1.0.1 + estree-walker: 2.0.2 + glob: 8.1.0 + is-reference: 1.2.1 + magic-string: 0.27.0 + rollup: 3.28.0 + dev: false + + /@rollup/plugin-node-resolve@15.1.0(rollup@3.28.0): + resolution: {integrity: sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.78.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.0.2(rollup@3.28.0) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-builtin-module: 3.2.1 + is-module: 1.0.0 + resolve: 1.22.4 + rollup: 3.28.0 + dev: false + + /@rollup/plugin-terser@0.4.3(rollup@3.28.0): + resolution: {integrity: sha512-EF0oejTMtkyhrkwCdg0HJ0IpkcaVg1MMSf2olHb2Jp+1mnLM04OhjpJWGma4HobiDTF0WCyViWuvadyE9ch2XA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.x || ^3.x + peerDependenciesMeta: + rollup: + optional: true + dependencies: + rollup: 3.28.0 + serialize-javascript: 6.0.1 + smob: 1.4.0 + terser: 5.19.2 + dev: false + + /@rollup/pluginutils@5.0.2(rollup@3.28.0): + resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@types/estree': 1.0.1 + estree-walker: 2.0.2 + picomatch: 2.3.1 + rollup: 3.28.0 + dev: false + /@types/archiver@5.3.2: resolution: {integrity: sha512-IctHreBuWE5dvBDz/0WeKtyVKVRs4h75IblxOACL92wU66v+HGAfEYAOyXkOFphvRJMhuXdI9huDXpX0FC6lCw==} dependencies: @@ -49,6 +191,10 @@ packages: '@types/node': 20.4.8 dev: true + /@types/estree@1.0.1: + resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} + dev: false + /@types/node@20.4.8: resolution: {integrity: sha512-0mHckf6D2DiIAzh8fM8f3HQCvMKDpK94YQ0DSVkfWTG9BZleYIWudw9cJxX8oCk9bM+vAkDyujDV6dmKHbvQpg==} dev: true @@ -59,10 +205,28 @@ packages: '@types/node': 20.4.8 dev: true + /@types/resolve@1.20.2: + resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} + dev: false + /@types/uuid@9.0.2: resolution: {integrity: sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==} dev: true + /acorn@8.10.0: + resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: false + + /anymatch@3.1.3: + resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} + engines: {node: '>= 8'} + dependencies: + normalize-path: 3.0.0 + picomatch: 2.3.1 + dev: false + /archiver-utils@2.1.0: resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==} engines: {node: '>= 6'} @@ -104,6 +268,11 @@ packages: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: false + /binary-extensions@2.2.0: + resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} + engines: {node: '>=8'} + dev: false + /bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} dependencies: @@ -125,10 +294,21 @@ packages: balanced-match: 1.0.2 dev: false + /braces@3.0.2: + resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} + engines: {node: '>=8'} + dependencies: + fill-range: 7.0.1 + dev: false + /buffer-crc32@0.2.13: resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: false + /buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: false + /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} dependencies: @@ -136,10 +316,38 @@ packages: ieee754: 1.2.1 dev: false + /builtin-modules@3.3.0: + resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} + engines: {node: '>=6'} + dev: false + + /chokidar@3.5.3: + resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} + engines: {node: '>= 8.10.0'} + dependencies: + anymatch: 3.1.3 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.2 + dev: false + /colorette@2.0.20: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} dev: false + /commander@2.20.3: + resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + dev: false + + /commondir@1.0.1: + resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + dev: false + /compress-commons@4.1.1: resolution: {integrity: sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==} engines: {node: '>= 10'} @@ -181,12 +389,45 @@ packages: which: 2.0.2 dev: false + /deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + dev: false + /end-of-stream@1.4.4: resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} dependencies: once: 1.4.0 dev: false + /estree-walker@2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + dev: false + + /fast-glob@3.3.1: + resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==} + engines: {node: '>=8.6.0'} + dependencies: + '@nodelib/fs.stat': 2.0.5 + '@nodelib/fs.walk': 1.2.8 + glob-parent: 5.1.2 + merge2: 1.4.1 + micromatch: 4.0.5 + dev: false + + /fastq@1.15.0: + resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} + dependencies: + reusify: 1.0.4 + dev: false + + /fill-range@7.0.1: + resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} + engines: {node: '>=8'} + dependencies: + to-regex-range: 5.0.1 + dev: false + /fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: false @@ -195,6 +436,25 @@ packages: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: false + /fsevents@2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /function-bind@1.1.1: + resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + dev: false + + /glob-parent@5.1.2: + resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} + engines: {node: '>= 6'} + dependencies: + is-glob: 4.0.3 + dev: false + /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: @@ -206,10 +466,28 @@ packages: path-is-absolute: 1.0.1 dev: false + /glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + dev: false + /graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} dev: false + /has@1.0.3: + resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: 1.1.1 + dev: false + /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: false @@ -225,6 +503,53 @@ packages: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: false + /is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + dependencies: + binary-extensions: 2.2.0 + dev: false + + /is-builtin-module@3.2.1: + resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} + engines: {node: '>=6'} + dependencies: + builtin-modules: 3.3.0 + dev: false + + /is-core-module@2.13.0: + resolution: {integrity: sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==} + dependencies: + has: 1.0.3 + dev: false + + /is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + dev: false + + /is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + dependencies: + is-extglob: 2.1.1 + dev: false + + /is-module@1.0.0: + resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} + dev: false + + /is-number@7.0.0: + resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} + engines: {node: '>=0.12.0'} + dev: false + + /is-reference@1.2.1: + resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} + dependencies: + '@types/estree': 1.0.1 + dev: false + /isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} dev: false @@ -260,6 +585,26 @@ packages: resolution: {integrity: sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==} dev: false + /magic-string@0.27.0: + resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: false + + /merge2@1.4.1: + resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} + engines: {node: '>= 8'} + dev: false + + /micromatch@4.0.5: + resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} + engines: {node: '>=8.6'} + dependencies: + braces: 3.0.2 + picomatch: 2.3.1 + dev: false + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -294,10 +639,29 @@ packages: engines: {node: '>=8'} dev: false + /path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + dev: false + + /picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: false + /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: false + /queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: false + + /randombytes@2.1.0: + resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} + dependencies: + safe-buffer: 5.2.1 + dev: false + /readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} dependencies: @@ -325,6 +689,41 @@ packages: minimatch: 5.1.6 dev: false + /readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + dependencies: + picomatch: 2.3.1 + dev: false + + /resolve@1.22.4: + resolution: {integrity: sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==} + hasBin: true + dependencies: + is-core-module: 2.13.0 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: false + + /reusify@1.0.4: + resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + dev: false + + /rollup@3.28.0: + resolution: {integrity: sha512-d7zhvo1OUY2SXSM6pfNjgD5+d0Nz87CUp4mt8l/GgVP3oBsPwzNvSzyu1me6BSG9JIgWNTVcafIXBIyM8yQ3yw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: false + + /run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + dependencies: + queue-microtask: 1.2.3 + dev: false + /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} dev: false @@ -333,6 +732,12 @@ packages: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: false + /serialize-javascript@6.0.1: + resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==} + dependencies: + randombytes: 2.1.0 + dev: false + /shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -345,6 +750,22 @@ packages: engines: {node: '>=8'} dev: false + /smob@1.4.0: + resolution: {integrity: sha512-MqR3fVulhjWuRNSMydnTlweu38UhQ0HXM4buStD/S3mc/BzX3CuM9OmhyQpmtYCvoYdl5ris6TI0ZqH355Ymqg==} + dev: false + + /source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + dev: false + + /source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + dev: false + /string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} dependencies: @@ -357,6 +778,11 @@ packages: safe-buffer: 5.2.1 dev: false + /supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + dev: false + /tar-stream@2.2.0: resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} engines: {node: '>=6'} @@ -368,6 +794,24 @@ packages: readable-stream: 3.6.2 dev: false + /terser@5.19.2: + resolution: {integrity: sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + '@jridgewell/source-map': 0.3.5 + acorn: 8.10.0 + commander: 2.20.3 + source-map-support: 0.5.21 + dev: false + + /to-regex-range@5.0.1: + resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} + engines: {node: '>=8.0'} + dependencies: + is-number: 7.0.0 + dev: false + /typescript@5.1.6: resolution: {integrity: sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==} engines: {node: '>=14.17'} diff --git a/src/commands/libpack.ts b/src/commands/libpack.ts new file mode 100644 index 0000000..10b03eb --- /dev/null +++ b/src/commands/libpack.ts @@ -0,0 +1,156 @@ +import * as path from "path"; +import * as fs from "fs/promises"; +import { Logger, assertSetup, loadConfig, pathExists, spawnBuilder, spawnLibBundler, spawnTranspiler } from "../common"; +import * as glob from "fast-glob"; + +export const runLibpack = async () => { + await assertSetup(); + const config = await loadConfig(); + + Logger.log("Creating production directory"); + if (await pathExists(path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}`))) { + Logger.error("Production build already exists, run 'yarn purge' if you'd like to delete it."); + throw Error("Production build already exists"); + } else { + try { + await fs.mkdir(path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}`), { recursive: true }); + } catch (e) { + Logger.error("Could not create production directory"); + throw e; + } + Logger.log("copying assets..."); + try { + await fs.cp(path.resolve("./assets"), path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}`), { recursive: true }); + } catch (e) { + Logger.error("Could not copy assets"); + throw e; + } + Logger.log("creating temporary build directory"); + try { + await fs.mkdir(path.resolve("./build"), { recursive: true }); + Logger.success("build directory created"); + } catch (e) { + Logger.error("Could not create build directory"); + throw e; + } + if (config.project.transpile || config.project.template === "typescript") { + Logger.notice("Transpiling typescript"); + try { + await spawnTranspiler(`./build/`); + Logger.success("Transpile Complete"); + } catch (e) { + Logger.error("Could not transpile"); + throw e; + } + } else { + Logger.notice("Copying javascript"); + try { + await fs.cp("./src", `./build/`, { recursive: true }); + Logger.success("Copy Complete"); + } catch (e) { + Logger.error("Could not copy scripts"); + throw e; + } + } + Logger.log("building dependencies"); + try { + await spawnBuilder(`./build/node_modules`); + } catch (e) { + Logger.error("Could not build dependencies"); + throw e; + } + Logger.log("gathering utilized scripts from template folders"); + try { + const templates = await glob.async("./assets/Templates/**/*.json"); + const scriptsToBundle = Object.keys( + (await Promise.all(templates.map(async (f) => JSON.parse(await fs.readFile(f, "utf-8"))))).reduce<{ [key: string]: boolean }>((acc, each) => { + if (each.ScriptName) { + acc[each.ScriptName] = true; + } + return acc; + }, {}) + ); + Logger.log("generating rollup config"); + try { + await fs.writeFile( + "./rollup.config.js", + + `module.exports = { + output: { + entryFileNames: "[name]", + dir: "lib", + format: "cjs", + exports: "named", + plugins: [require("@rollup/plugin-terser")()], + }, + input: {${scriptsToBundle.reduce((acc, fname) => { + return `${acc}'${fname}': "./build/${fname}",`; + }, "")}}, + plugins: [require("@rollup/plugin-node-resolve").nodeResolve(), require("@rollup/plugin-commonjs")()], + external: ['@tabletop-playground/api'] + }`, + "utf8" + ); + } catch (e) { + Logger.error("could not generate rollup config"); + throw e; + } + } catch (e) { + Logger.error("could not glob files"); + throw e; + } + Logger.log("lib-packing"); + try { + await spawnLibBundler(); + Logger.success("it should've built?"); + } catch (e) { + Logger.error("could not lib-pack"); + throw e; + } + Logger.log("copying scripts to production directory"); + try { + await fs.cp(path.resolve("./lib"), path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}`, "Scripts"), { recursive: true }); + Logger.success("scripts copied to production directory"); + } catch (e) { + Logger.error("Could not copy lib to production directory"); + } + Logger.log("removing temporary build directory"); + try { + await fs.rm(path.resolve("./build"), { recursive: true }); + Logger.success("temporary build directory removed"); + } catch (e) { + Logger.error("Could not remove temporary build directory"); + throw e; + } + Logger.log("removing temporary lib directory"); + try { + await fs.rm(path.resolve("./lib"), { recursive: true }); + Logger.success("temporary lib directory removed"); + } catch (e) { + Logger.error("Could not remove temporary lib directory"); + throw e; + } + Logger.log("removing temporary rollup config"); + try { + await fs.rm(path.resolve("./rollup.config.js"), { recursive: true }); + Logger.success("temporary rollup config removed"); + } catch (e) { + Logger.error("Could not remove temporary rollup config"); + throw e; + } + const manifest = { + Name: config.project.name, + Version: config.project.version, + GUID: config.project.guid.prd, + }; + Logger.log("writing production manifest"); + try { + await fs.writeFile(path.resolve(config.local.ttpg_path, `${config.project.slug}`, "Manifest.json"), JSON.stringify(manifest, null, 2), "utf-8"); + Logger.success("manifest written"); + } catch (e) { + Logger.error("Could not write production manifest"); + throw e; + } + Logger.success("Your project is ready to be deployed to mod.io"); + } +}; diff --git a/src/commands/watch.ts b/src/commands/watch.ts new file mode 100644 index 0000000..8e2b9d9 --- /dev/null +++ b/src/commands/watch.ts @@ -0,0 +1,69 @@ +import * as path from "path"; +import * as fs from "fs/promises"; +import { assertSetup, pathExists, Logger, ASSET_DIRS, loadConfig, spawnBuilder, spawnTranspiler, spawnTranspilingWatcher } from "../common"; + +export const runWatch = async () => { + await assertSetup(); + + const config = await loadConfig(); + + if (!(await pathExists(path.resolve("./dev/", `${config.project.slug}_dev`)))) { + try { + const manifest = { + Name: `${config.project.name} (Dev)`, + Version: config.project.version, + GUID: config.project.guid.dev, + }; + + await fs.mkdir(path.resolve("./dev", `${config.project.slug}_dev`), { recursive: true }); + await fs.writeFile(path.resolve("./dev/", `${config.project.slug}_dev`, "Manifest.json"), JSON.stringify(manifest, null, 2), "utf8"); + await Promise.all(ASSET_DIRS.map((dir) => fs.symlink(path.resolve("assets", dir), path.resolve("dev", `${config.project.slug}_dev`, dir), "junction"))); + } catch (e) { + Logger.error("Failed to create dev folder"); + throw e; + } + } + + if (!(await pathExists(path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}_dev`)))) { + Logger.notice("symlinking ./dev folder into ttpg"); + try { + await fs.symlink(path.resolve("./dev", `${config.project.slug}_dev`), path.join(path.resolve(config.local.ttpg_path), `${config.project.slug}_dev`), "junction"); + } catch (e) { + Logger.error("Could not symlink dev folder to ttpg folder"); + throw e; + } + } + if (config.project.transpile || config.project.template === "typescript") { + Logger.notice("Transpiling typescript"); + try { + await spawnTranspiler(`./dev/${config.project.slug}_dev/Scripts/`); + Logger.success("Transpile Complete"); + } catch (e) { + Logger.error("Could not transpile"); + throw e; + } + } else { + Logger.notice("Copying javascript"); + try { + await fs.cp("./src", `./dev/${config.project.slug}_dev/Scripts/`, { recursive: true }); + Logger.success("Copy Complete"); + } catch (e) { + Logger.error("Could not copy scripts"); + throw e; + } + } + Logger.log("building dependencies"); + try { + await spawnBuilder(`./dev/${config.project.slug}_dev/Scripts/node_modules`); + } catch (e) { + Logger.error("Could not build dependencies"); + throw e; + } + Logger.log("starting watcher"); + try { + await spawnTranspilingWatcher(`./src/`, `./dev/${config.project.slug}_dev/Scripts/`, config.project.transpile || config.project.template === "typescript"); + } catch (e) { + Logger.error("something went wrong with the watcher"); + throw e; + } +}; diff --git a/src/common.ts b/src/common.ts index 1a34296..44904cf 100644 --- a/src/common.ts +++ b/src/common.ts @@ -4,6 +4,7 @@ import * as readline from "readline/promises"; import * as chalk from "colorette"; import { v4 as uuid } from "uuid"; import { spawn } from "cross-spawn"; +import * as chokidar from "chokidar"; export const ASSET_DIRS = ["Fonts", "Models", "Sounds", "States", "Templates", "Textures", "Thumbnails"] as const; @@ -179,7 +180,7 @@ export const guid = () => uuid().replace(/-/g, "").toUpperCase(); export const spawnBuilder = (target: string) => { return new Promise((resolve, reject) => { - const child = spawn("yarn", ["install", "--modules-folder", target, "--prod"], { stdio: "pipe", cwd: process.cwd() }); + const child = spawn("yarn", ["install", "--modules-folder", target, "--prod"], { stdio: "inherit", cwd: process.cwd() }); child.on("close", (code: number) => (code === 0 ? resolve(0) : undefined)); child.on("error", (e) => reject(e)); }); @@ -187,8 +188,45 @@ export const spawnBuilder = (target: string) => { export const spawnTranspiler = (target: string) => { return new Promise((resolve, reject) => { - const child = spawn("tsc", ["--outDir", target], { stdio: "pipe", env: process.env }); + const child = spawn("tsc", ["--outDir", target], { stdio: "inherit", env: process.env }); child.on("close", (code: number) => (code === 0 ? resolve(0) : undefined)); child.on("error", (e) => reject(e)); }); }; + +export const spawnTranspilingWatcher = (source: string, dest: string, transpile: boolean) => { + if (transpile) { + return new Promise((resolve, reject) => { + Logger.success("watching files"); + const child = spawn("tsc", ["--watch", "--outDir", dest], { stdio: "inherit", env: process.env }); + child.on("close", (code: number) => (code === 0 ? resolve(0) : undefined)); + child.on("error", (e) => reject(e)); + }); + } else { + return new Promise((resolve, reject) => { + Logger.success("watching files"); + const watcher = chokidar.watch("./**", { cwd: "./src", ignored: /(^|[/\\])\../ }); + const doCopy = (path: string) => { + Logger.notice(path); + fs.cp(`./src/${path}`, `${dest}/${path}`, { recursive: true }).catch((e) => { + //console.error(e); + }); + }; + + watcher.on("add", doCopy); + watcher.on("addDir", doCopy); + watcher.on("change", doCopy); + watcher.on("error", (e) => { + reject(e); + }); + }); + } +}; + +export const spawnLibBundler = () => { + return new Promise((resolve, reject) => { + const child = spawn("rollup", ["-c"], { stdio: "inherit", env: process.env, cwd: process.cwd() }); + child.on("close", (code: number) => (code === 0 ? resolve(0) : reject(-1))); + child.on("error", (e) => reject(e)); + }); +}; diff --git a/src/help.ts b/src/help.ts new file mode 100644 index 0000000..bfe3406 --- /dev/null +++ b/src/help.ts @@ -0,0 +1,31 @@ +import { Logger } from "./common"; + +export const runHelp = () => { + Logger.log(""); + Logger.notice("setup"); + Logger.log("run this to make sure all your configurations and asset folders are in place."); + Logger.log(""); + Logger.notice("dev"); + Logger.log("run this command to place a development version of your package into ttpg."); + Logger.log(""); + Logger.notice("watch"); + Logger.log("spawns a watcher that will copy any file you change (and save) in your src folder into your dev folder, meaning changes will live update into your develeopement build within ttpg"); + Logger.log(""); + Logger.notice("reset"); + Logger.log("run this to clear and reset your local config. If you need to change your ttpg directory, this is how you do it."); + Logger.log(""); + Logger.notice("clean"); + Logger.log("removes the development version of your package from ttpg - no actual data is lost, it just removes the symlink."); + Logger.log(""); + Logger.notice("build"); + Logger.log("creates a production version of your package and places it into ttpg, ready for upload to mod.io."); + Logger.log(""); + Logger.notice("purge"); + Logger.log("removes the production version of your package from ttpg, if it exists."); + Logger.log(""); + Logger.notice("libpack"); + Logger.log("builds a production version of your package where every script used by a template is completely self-contained and minified."); + Logger.log("Use this if you intend to make a package with scripted objects for others to import into their package or table-state."); + Logger.warning("libpack will bundle *all* dependencies into every script for portabilities sake. Use with care."); + Logger.log(""); +}; diff --git a/src/index.ts b/src/index.ts index cab5101..fbb1b92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node -import * as chalk from "colorette"; import { runSetup } from "./commands/setup"; import { runStatus } from "./commands/status"; import { runDev } from "./commands/dev"; @@ -10,6 +9,9 @@ import { Logger, guid } from "./common"; import { runBuild } from "./commands/build"; import { runPurge } from "./commands/purge"; import path = require("path"); +import { runLibpack } from "./commands/libpack"; +import { runHelp } from "./help"; +import { runWatch } from "./commands/watch"; const cmd = process.argv[2] ?? "setup"; @@ -21,6 +23,9 @@ const HANDLERS = { setup: runSetup, build: runBuild, purge: runPurge, + libpack: runLibpack, + help: runHelp, + watch: runWatch, } as const; const runCommand = async () => {