From 15f8964920bf5a9f36220eac5b91bdb018c9aa1d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 27 Apr 2021 15:13:05 -0500 Subject: [PATCH 1/2] feat: add minimal create-astro CLI --- .eslintignore | 1 + create-astro/bin.js | 4 + create-astro/index.js | 47 ++++ create-astro/package-lock.json | 372 ++++++++++++++++++++++++++ create-astro/package.json | 17 ++ create-astro/templates/starter.tar.gz | Bin 0 -> 3819 bytes examples/starter/astro.config.mjs | 16 ++ 7 files changed, 457 insertions(+) create mode 100755 create-astro/bin.js create mode 100644 create-astro/index.js create mode 100644 create-astro/package-lock.json create mode 100644 create-astro/package.json create mode 100644 create-astro/templates/starter.tar.gz create mode 100644 examples/starter/astro.config.mjs diff --git a/.eslintignore b/.eslintignore index 7c46fa8fe1ac..e1a97dc5eb61 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ src/parser/parse/**/*.ts vscode/**/*.ts +create-astro/**/*.js diff --git a/create-astro/bin.js b/create-astro/bin.js new file mode 100755 index 000000000000..efc9a015355e --- /dev/null +++ b/create-astro/bin.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +import cli from './index.js'; + +cli(process.argv); diff --git a/create-astro/index.js b/create-astro/index.js new file mode 100644 index 000000000000..cb3823d2ebb8 --- /dev/null +++ b/create-astro/index.js @@ -0,0 +1,47 @@ +import * as fs from 'fs'; +import { resolve } from 'path'; +import decompress from 'decompress'; +import { fileURLToPath, URL } from 'url'; +import { join } from 'node:path'; + +const log = (...args) => console.log(' ', ...args); +export default async function createAstro(argv) { + const [name] = argv.slice(2); + const templateRoot = fileURLToPath(new URL('../create-astro/templates', import.meta.url)); + if (!name) { + log(); + log(`npm init astro `); + log(`Provide a destination!`); + process.exit(0); + } + + log(); + const dest = resolve(process.cwd(), name); + const relDest = `./${name}`; + if (isEmpty(relDest)) { + await decompress(fs.readFileSync(join(templateRoot, 'starter.tar.gz')), dest); + log(`Your Astro project has been scaffolded at "${relDest}"`); + log(); + log(`Next steps:`); + log(); + log(` cd ${relDest}`); + log(` npm install`); + log(` npm run start`); + } +} + +function isEmpty(path) { + try { + const files = fs.readdirSync(resolve(process.cwd(), path)); + if (files.length > 0) { + log(`It looks like "${path}" isn't empty!`); + return false; + } else { + log(`Scaffolding Astro project at "${path}"`); + return true; + } + } catch (err) { + if (err.code !== 'ENOENT') throw err; + } + return true; +} diff --git a/create-astro/package-lock.json b/create-astro/package-lock.json new file mode 100644 index 000000000000..744f946e4e55 --- /dev/null +++ b/create-astro/package-lock.json @@ -0,0 +1,372 @@ +{ + "name": "create-astro", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "bl": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "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=" + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "decompress": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.1.tgz", + "integrity": "sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ==", + "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" + } + }, + "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" + } + }, + "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" + } + }, + "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=" + } + } + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "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" + } + }, + "file-type": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz", + "integrity": "sha1-LdvqfHP/42No365J3DOMBYwritY=" + }, + "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==" + }, + "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" + } + }, + "graceful-fs": { + "version": "4.2.6", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", + "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==" + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "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-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", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "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" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + } + } + }, + "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" + } + }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "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" + } + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "seek-bzip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", + "integrity": "sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==", + "requires": { + "commander": "^2.8.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, + "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" + } + }, + "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": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "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==" + }, + "unbzip2-stream": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", + "requires": { + "buffer": "^5.2.1", + "through": "^2.3.8" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, + "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/create-astro/package.json b/create-astro/package.json new file mode 100644 index 000000000000..1368b66a05c9 --- /dev/null +++ b/create-astro/package.json @@ -0,0 +1,17 @@ +{ + "name": "create-astro", + "version": "0.0.1", + "type": "module", + "main": "./index.js", + "files": [ + "templates", + "bin.js", + "index.js" + ], + "bin": { + "create-astro": "./bin.js" + }, + "dependencies": { + "decompress": "^4.2.1" + } +} diff --git a/create-astro/templates/starter.tar.gz b/create-astro/templates/starter.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..858c7830c5104c97666e25d8ff6992c5aa2d861f GIT binary patch literal 3819 zcmVHnn%N zyEC)1JF|1UcdIpO*ABX_yS9yZ>WEY~ERjk;*wQUScU)IDk&dxx;u^BAU$k0noaH11 zQQ{~`UR4f?_4}{Lm+hFQzYx$GB+Ju8^OLwA47BKZwt60*567}D?tjxYXZ>$F(EpZY zL;vfm7iAgV^8TkMqa@8ykM_wp%+WV>ghpxdocj5*B*|N7OWWE393LbFrjeyS$M%9u zAlL=RjKc^|VMcc(G793Lf7(KMI-cU7TL+YhM>9jm-j=|>l&oIfuiv!l-w4ne z&mKSAd-_<5de_F|68p!l;S~07V8a0WHyqun?0+4wiN2trpF|Yp3HtIOGxNXS9p?Ec zYc=H5&>aV1Z@XUapdY{g@3%jk{p-i?|9yt;-8-NpOJdp+&LJk_{QZ0P&>jtG4%CK0 zhWbHBHS`ggP}CpC@7C*^n}}EbRJa&)00!&l zX^ zHllt&LPWYiMDQ+Y?Pv#_dJbZd9O@jiy6BjqFnGZSW89xNt`h`bdZN6d1> zZ4vk@P;ifqC`@{>AJ7s(U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DS6j0NGkqczN9g8*~2LBNwH%*U3499^@WtHl5oD$>`80lXUy0_Zv#aJAt;oZ#< z3F2J;ihb=$(rslWVS(v@QoXsjz`CBWz$k|W#$s4t&xHlfFDxuDOJRZgT44bgicE^I zz^cN6^})jWe{m|+N_ku||6|i$Jpb1=-Rk?FwLmLPl3dQ8rE?8h=z}EAl8|IONO>6d zNJ!CBz@sk?m3a)ieKPig9+6dO33EW=3>}`1=y4k4G-Ww^^f~!_EOLtakAghQQ%WNA zIZerY-jkpUIDX_sf%-Uzx?@oSJplw<5I=#850Y^j&=h@4j{z<3b`Wb&HX=T~FPm99 zn1KZ(=DxM>+^@f^*Iz%@DC_M!qIlnEnr?Ae0+1%MFfZ0ZK|G|O6V6p0^~MfXnaEP5 zb25CG%tm+FSs6R*5C+S&*fn~OO-`QeOpbS8#&&JMZC^y~oP$7KbqEMQyF-Nzi?Z1X z9y7{Aye#DOxDbvzmM2iyy3Q)fdhD1tQBj^HGCi!MII#j|3ddzg#>^;lnWK2Ff?!7D zD#AiJSTk&{nnEu(ZD?;OEcpM~QHCqzaoPT#>n=V2LC8}1|8>AUX=UBygqagR1xB7w z11Mo@(?ejmVU|7L+|fAMX$CGs9S2Jmil+ztsOp$)IEp-Wgr~?vDg>y-K{!jMtwTg9 zj2qmaV>pF{>+l#gIfhGd+|B~!?H%?&VayyOJCISzJw5QoVzg%G5J|^`b$xOy+aAQT z19bo`4?miE)Il2b1nN1Aq@aJQ%HvDt&ps+24z#)7+<& Date: Tue, 27 Apr 2021 15:57:54 -0500 Subject: [PATCH 2/2] docs: update readme --- README.md | 90 +++++++++++++++----------------------------------- docs/config.md | 33 ++++++++++++++++++ 2 files changed, 59 insertions(+), 64 deletions(-) create mode 100644 docs/config.md diff --git a/README.md b/README.md index 157ae4ad16bf..a89ed9a70ee8 100644 --- a/README.md +++ b/README.md @@ -1,75 +1,54 @@ ![Astro](./assets/social/banner.png) -**Astro** is a next-generation static-site generator with partial hydration. Use your favorite JS framework and ship bare-minimum JS (or none at all!). +**Astro** is a _fresh but familiar_ approach to building websites. Astro combines decades of proven performance best practices with the DX improvements of the component-oriented era. + +With Astro, you can use your favorite JavaScript framework and automatically ship the bare-minimum amount of JavaScriptโ€”by default, it's none at all! ## ๐Ÿ”ง Setup ```bash -# currently hidden during private beta, please don't share :) -npm install astro@shhhhh +# currently "hidden" during private beta +npm init astro@shhhhh ./my-astro-project -# NOTE: There is currently a bug in Snowpack that prevents you -# from using astro outside of the monorepo setup that we have here. -# For now, do all development inside the `examples/` directory for this repo. +# then... cd => install => start +cd ./my-astro-project +npm install +npm start ``` -## ๐Ÿงž Development +### ๐Ÿš€ Build & Deployment -Add a `dev` npm script to your `/package.json` file: +The default Astro project has the following `scripts` in the `/package.json` file: ```json { "scripts": { - "dev": "astro dev ." + "start": "astro dev .", + "build": "astro build ." } } ``` -Then run: +For local development, run: ``` -npm run dev +npm run start ``` -### โš™๏ธ Configuration +To build for production, run the following command: -To configure Astro, add a `astro.config.mjs` file in the root of your project. All settings are optional. Here are the defaults: - -```js -export default { - /** Where to resolve all URLs relative to. Useful if you have a monorepo project. */ - projectRoot: '.', - /** Path to Astro components, pages, and data */ - astroRoot: './src', - /** When running `astro build`, path to final static output */ - dist: './dist', - /** A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that donโ€™t need processing. */ - public: './public', - /** Extension-specific handlings */ - extensions: { - /** Set this to "preact" or "react" to determine what *.jsx files should load */ - '.jsx': 'react', - }, - /** Options specific to `astro build` */ - buildOptions: { - /** Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs. */ - site: '', - /** Generate sitemap (set to "false" to disable) */ - sitemap: true, - }, - /** Options for the development server run with `astro dev`. */ - devOptions: { - /** The port to run the dev server on. */ - port: 3000, - }, -}; ``` +npm run build +``` + +To deploy your Astro site to production, upload the contents of `/dist` to your favorite static site host. + ## ๐Ÿฅพ Guides ### ๐Ÿš€ Basic Usage -Even though nearly-everything [is configurable][config], we recommend starting out by creating an `src/` folder in your project with the following structure: +Even though nearly-everything [is configurable][docs-config], we recommend starting out by creating an `src/` folder in your project with the following structure: ``` โ”œโ”€โ”€ src/ @@ -166,7 +145,7 @@ const localData = Astro.fetchContent('../post/*.md'); ### ๐Ÿ—บ๏ธ Sitemap -Astro will automatically create a `/sitemap.xml` for you for SEO! Be sure to set `buildOptions.site` in your [Astro config][config] so the URLs can be generated properly. +Astro will automatically create a `/sitemap.xml` for you for SEO! Be sure to set `buildOptions.site` in your [Astro config][docs-config] so the URLs can be generated properly. โš ๏ธ Note that Astro wonโ€™t inject this into your HTML for you! Youโ€™ll have to add the tag yourself in your `` on all pages that need it: @@ -185,27 +164,10 @@ Astro will automatically create a `/sitemap.xml` for you for SEO! Be sure to set ๐Ÿ‘‰ [**Collections API**][docs-collections] -### ๐Ÿš€ Build & Deployment - -Add a `build` npm script to your `/package.json` file: - -```json -{ - "scripts": { - "dev": "astro dev .", - "build": "astro build ." - } -} -``` - -Then run: - -``` -npm run build -``` -Now upload the contents of `/dist` to your favorite static site host. +## โš™๏ธ Config +๐Ÿ‘‰ [**`astro.config.mjs` Reference**][docs-config] ## ๐Ÿ“š API ๐Ÿ‘‰ [**Full API Reference**][docs-api] @@ -218,7 +180,7 @@ Now upload the contents of `/dist` to your favorite static site host. ๐Ÿ‘‰ [**Dev Server Docs**][docs-dev] -[config]: #%EF%B8%8F-configuration +[docs-config]: ./docs/config.md [docs-api]: ./docs/api.md [docs-collections]: ./docs/collections.md [docs-dev]: ./docs/dev.md diff --git a/docs/config.md b/docs/config.md new file mode 100644 index 000000000000..8ea7487af3f1 --- /dev/null +++ b/docs/config.md @@ -0,0 +1,33 @@ +# โš™๏ธ Configuration + +To configure Astro, add an `astro.config.mjs` file in the root of your project. All settings are optional. Here are the defaults: + +```js +export default { + /** Where to resolve all URLs relative to. Useful if you have a monorepo project. */ + projectRoot: '.', + /** Path to Astro components, pages, and data */ + astroRoot: './src', + /** When running `astro build`, path to final static output */ + dist: './dist', + /** A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that donโ€™t need processing. */ + public: './public', + /** Extension-specific handlings */ + extensions: { + /** Set this to "preact" or "react" to determine what *.jsx files should load */ + '.jsx': 'react', + }, + /** Options specific to `astro build` */ + buildOptions: { + /** Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs. */ + site: '', + /** Generate sitemap (set to "false" to disable) */ + sitemap: true, + }, + /** Options for the development server run with `astro dev`. */ + devOptions: { + /** The port to run the dev server on. */ + port: 3000, + }, +}; +```