wip(new-design): Work on standalone dev env
This commit is contained in:
parent
640b7231be
commit
437d444462
6 changed files with 128 additions and 21 deletions
|
@ -148,6 +148,15 @@ mui-theme:
|
|||
'@material-ui/core': *matui-core
|
||||
'react': *react
|
||||
'react-dom': '^17.0.2'
|
||||
new-design:
|
||||
_:
|
||||
"axios": "^0.27.2"
|
||||
"chalk": "^5.0.1"
|
||||
"execa": "^6.1.0"
|
||||
"mustache": "^4.2.0"
|
||||
"ora": "^6.1.0"
|
||||
"prompts": "^2.4.2"
|
||||
"recursive-readdir": "^2.2.2"
|
||||
noble:
|
||||
peer:
|
||||
'@freesewing/bella': *freesewing
|
||||
|
|
|
@ -17,8 +17,8 @@ const options = {
|
|||
entryPoints: ['index.mjs'],
|
||||
external: [],
|
||||
metafile: process.env.VERBOSE ? true : false,
|
||||
minify: process.env.NO_MINIFY ? false : true,
|
||||
sourcemap: true,
|
||||
minify: false, //process.env.NO_MINIFY ? false : true,
|
||||
sourcemap: false,
|
||||
platform: "node",
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
export const config = {
|
||||
node: 14, // Minimum node version
|
||||
fileUri: 'https://raw.githubusercontent.com',
|
||||
repo: 'freesewing/freesewing', // Repository to download from
|
||||
branch: 'develop', // Branch to download from
|
||||
i18n: [
|
||||
|
@ -32,6 +33,7 @@ export const config = {
|
|||
"shared/config/postcss.config.js",
|
||||
"shared/config/tailwind.config.js",
|
||||
"shared/prebuild/contributors.mjs",
|
||||
"shared/hooks/useGist.js",
|
||||
"shared/hooks/useLocalStorage.js",
|
||||
"shared/hooks/useTheme.js",
|
||||
"shared/styles/code.css",
|
||||
|
|
|
@ -8,7 +8,14 @@ import prompts from 'prompts'
|
|||
import {oraPromise} from 'ora'
|
||||
import { execa } from 'execa'
|
||||
import axios from 'axios'
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// Current working directory
|
||||
const cwd = __dirname
|
||||
? __dirname
|
||||
: dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
console.log({cwd})
|
||||
const nl = "\n"
|
||||
const tab = " "
|
||||
const nlt = nl+tab
|
||||
|
@ -93,15 +100,15 @@ const copyTemplate = async (config, choices) => {
|
|||
|
||||
// Copy shared files
|
||||
for (const from of config.files.shared) {
|
||||
const to = config.dest + from.slice(config.source.shared.length)
|
||||
// FIXME: Explain the -7
|
||||
const to = join(config.dest, from.slice(config.source.shared.length - 7))
|
||||
if (!dirs[to]) await ensureDir(to)
|
||||
console.log(to)
|
||||
promises.push(copyFile(from, to))
|
||||
}
|
||||
|
||||
// Template files
|
||||
for (const from of config.files.template) {
|
||||
const to = config.dest + from.slice(config.source.template.length)
|
||||
const to = join(config.dest, from.slice(config.source.template.length -7))
|
||||
if (!dirs[to]) await ensureDir(to)
|
||||
if (extname(from) === '.json') {
|
||||
// Template out package.json
|
||||
|
@ -131,7 +138,6 @@ const installDependencies = async (config, choices) => await execa(
|
|||
|
||||
// Helper method to download web environment
|
||||
const downloadLabFiles = async (config) => {
|
||||
const base = 'https://raw.githubusercontent.com'
|
||||
const promises = []
|
||||
for (const dir in config.fetch) {
|
||||
for (const file of config.fetch[dir]) {
|
||||
|
@ -139,9 +145,8 @@ const downloadLabFiles = async (config) => {
|
|||
? join(config.dest, file)
|
||||
: join(config.dest, file.to)
|
||||
if (!dirs[to]) await ensureDir(to)
|
||||
console.log(to)
|
||||
promises.push(
|
||||
axios.get(`${base}/${config.repo}/${config.branch}/${dir}/${typeof file === 'string' ? file : file.from}`)
|
||||
axios.get(`${config.fileUri}/${config.repo}/${config.branch}/${dir}/${typeof file === 'string' ? file : file.from}`)
|
||||
.catch(err => console.log(err))
|
||||
.then(res => promises.push(writeFile(to, res.data)))
|
||||
)
|
||||
|
@ -157,13 +162,13 @@ const downloadLabFiles = async (config) => {
|
|||
export const createEnvironment = async (choices) => {
|
||||
|
||||
// Store directories for re-use
|
||||
config.cwd = process.cwd()
|
||||
config.cwd = cwd,
|
||||
config.source = {
|
||||
root: dirname(process.argv[1]),
|
||||
template: dirname(process.argv[1]) + `/templates/from-${choices.template}`,
|
||||
shared: dirname(process.argv[1]) + `/shared`
|
||||
root: cwd,
|
||||
template: cwd + `/../templates/from-${choices.template}`,
|
||||
shared: cwd + `/../shared`
|
||||
}
|
||||
config.dest = join(config.cwd, choices.name)
|
||||
config.dest = join(process.cwd(), choices.name)
|
||||
|
||||
// Create target directory
|
||||
await mkdir(config.dest, { recursive: true })
|
||||
|
@ -175,18 +180,33 @@ export const createEnvironment = async (choices) => {
|
|||
}
|
||||
|
||||
// Copy/Template files
|
||||
await copyTemplate(config, choices)
|
||||
await oraPromise(
|
||||
copyTemplate(config, choices),
|
||||
{
|
||||
text: chalk.white.bold(' 🟨⬜⬜ Copying template files')+chalk.white.dim(' | Just a moment'),
|
||||
successText: chalk.white.bold(' 🟩⬜⬜ Copied template files'),
|
||||
failText: chalk.white.bold(' 🟥⬜⬜ Failed to copy template files'),
|
||||
}
|
||||
)
|
||||
|
||||
// Install dependencies
|
||||
await oraPromise(
|
||||
installDependencies(config, choices),
|
||||
chalk.white.bold('Installing dependencies')+chalk.white.dim(' (This will take a while)')
|
||||
{
|
||||
text: chalk.white.bold(' 🟩🟨⬜ Installing dependencies')+chalk.white.dim(' | Please wait, this will take a while'),
|
||||
successText: chalk.white.bold(' 🟩🟩⬜ Installed dependencies'),
|
||||
failText: chalk.white.bold(' 🟩🟥⬜ Failed to install dependencies'),
|
||||
}
|
||||
)
|
||||
|
||||
// Fetch web components
|
||||
await oraPromise(
|
||||
downloadLabFiles(config),
|
||||
chalk.white.bold('Downloading web components')+chalk.white.dim(' (This too will take a while)')
|
||||
{
|
||||
text: chalk.white.bold(' 🟩🟩🟨 Downloading web components')+chalk.white.dim(' | Almost there'),
|
||||
successText: chalk.white.bold(' 🟩🟩🟩 Downloaded web components'),
|
||||
failText: chalk.white.bold(' 🟩🟩🟥 Failed to download web components'),
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,15 @@
|
|||
"cibuild_step6": "node build.js"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"chalk": "^5.0.1",
|
||||
"execa": "^6.1.0",
|
||||
"mustache": "^4.2.0",
|
||||
"ora": "^6.1.0",
|
||||
"prompts": "^2.4.2",
|
||||
"recursive-readdir": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"files": [
|
||||
"README.md",
|
||||
|
|
76
yarn.lock
76
yarn.lock
|
@ -6611,6 +6611,14 @@ axios@^0.25.0:
|
|||
dependencies:
|
||||
follow-redirects "^1.14.7"
|
||||
|
||||
axios@^0.27.2:
|
||||
version "0.27.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.9"
|
||||
form-data "^4.0.0"
|
||||
|
||||
axobject-query@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
||||
|
@ -7561,6 +7569,15 @@ bl@^4.0.3, bl@^4.1.0:
|
|||
inherits "^2.0.4"
|
||||
readable-stream "^3.4.0"
|
||||
|
||||
bl@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bl/-/bl-5.0.0.tgz#6928804a41e9da9034868e1c50ca88f21f57aea2"
|
||||
integrity sha512-8vxFNZ0pflFfi0WXA3WQXlj6CaMEwsmh63I1CNp0q+wWv8sD0ARx1KovSQd0l2GkwrMIOyedq0EF1FxI+RCZLQ==
|
||||
dependencies:
|
||||
buffer "^6.0.3"
|
||||
inherits "^2.0.4"
|
||||
readable-stream "^3.4.0"
|
||||
|
||||
bluebird@3.5.1:
|
||||
version "3.5.1"
|
||||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"
|
||||
|
@ -7918,6 +7935,14 @@ buffer@^5.1.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0:
|
|||
base64-js "^1.3.1"
|
||||
ieee754 "^1.1.13"
|
||||
|
||||
buffer@^6.0.3:
|
||||
version "6.0.3"
|
||||
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
|
||||
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
|
||||
dependencies:
|
||||
base64-js "^1.3.1"
|
||||
ieee754 "^1.2.1"
|
||||
|
||||
build-array@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/build-array/-/build-array-1.0.0.tgz#385e66f6b05c29ff16870c6e9944ccae77f7f100"
|
||||
|
@ -8380,6 +8405,11 @@ chalk@^5.0.0:
|
|||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.0.tgz#bd96c6bb8e02b96e08c0c3ee2a9d90e050c7b832"
|
||||
integrity sha512-/duVOqst+luxCQRKEo4bNxinsOQtMP80ZYm7mMqzuh5PociNL0PvmHFvREJ9ueYL2TxlHjBcmLCdmocx9Vg+IQ==
|
||||
|
||||
chalk@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6"
|
||||
integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==
|
||||
|
||||
char-regex@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
|
||||
|
@ -8674,7 +8704,7 @@ cli-progress@^3.7.0:
|
|||
dependencies:
|
||||
string-width "^4.2.0"
|
||||
|
||||
cli-spinners@^2.5.0:
|
||||
cli-spinners@^2.5.0, cli-spinners@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.6.1.tgz#adc954ebe281c37a6319bfa401e6dd2488ffb70d"
|
||||
integrity sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==
|
||||
|
@ -12064,7 +12094,7 @@ execa@^5.0.0, execa@^5.1.0, execa@^5.1.1:
|
|||
signal-exit "^3.0.3"
|
||||
strip-final-newline "^2.0.0"
|
||||
|
||||
execa@^6.0.0:
|
||||
execa@^6.0.0, execa@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/execa/-/execa-6.1.0.tgz#cea16dee211ff011246556388effa0818394fb20"
|
||||
integrity sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==
|
||||
|
@ -12725,6 +12755,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0, follow-redirects@^1.14.7, fol
|
|||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
|
||||
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
|
||||
|
||||
follow-redirects@^1.14.9:
|
||||
version "1.15.1"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
|
||||
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
|
||||
|
||||
font-awesome@^4.7.0:
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/font-awesome/-/font-awesome-4.7.0.tgz#8fa8cf0411a1a31afd07b06d2902bb9fc815a133"
|
||||
|
@ -14461,7 +14496,7 @@ identity-obj-proxy@^3.0.0:
|
|||
dependencies:
|
||||
harmony-reflect "^1.4.6"
|
||||
|
||||
ieee754@^1.1.13, ieee754@^1.1.4:
|
||||
ieee754@^1.1.13, ieee754@^1.1.4, ieee754@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
|
||||
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
|
||||
|
@ -15151,6 +15186,11 @@ is-interactive@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e"
|
||||
integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==
|
||||
|
||||
is-interactive@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-2.0.0.tgz#40c57614593826da1100ade6059778d597f16e90"
|
||||
integrity sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==
|
||||
|
||||
is-ip@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-2.0.0.tgz#68eea07e8a0a0a94c2d080dd674c731ab2a461ab"
|
||||
|
@ -15448,6 +15488,11 @@ is-unicode-supported@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.1.0.tgz#9127b71f9fa82f52ca5c20e982e7bec0ee31ee1e"
|
||||
integrity sha512-lDcxivp8TJpLG75/DpatAqNzOpDPSpED8XNtrpBHTdQ2InQ1PbW78jhwSxyxhhu+xbVSast2X38bwj8atwoUQA==
|
||||
|
||||
is-unicode-supported@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.2.0.tgz#f4f54f34d8ebc84a46b93559a036763b6d3e1014"
|
||||
integrity sha512-wH+U77omcRzevfIG8dDhTS0V9zZyweakfD01FULl97+0EHiJTTZtJqxPSkIIo/SDPv/i07k/C9jAPY+jwLLeUQ==
|
||||
|
||||
is-url-superb@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-url-superb/-/is-url-superb-4.0.0.tgz#b54d1d2499bb16792748ac967aa3ecb41a33a8c2"
|
||||
|
@ -17339,6 +17384,14 @@ log-symbols@^1.0.2:
|
|||
dependencies:
|
||||
chalk "^1.0.0"
|
||||
|
||||
log-symbols@^5.1.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-5.1.0.tgz#a20e3b9a5f53fac6aeb8e2bb22c07cf2c8f16d93"
|
||||
integrity sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==
|
||||
dependencies:
|
||||
chalk "^5.0.0"
|
||||
is-unicode-supported "^1.1.0"
|
||||
|
||||
log-update@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/log-update/-/log-update-2.3.0.tgz#88328fd7d1ce7938b29283746f0b1bc126b24708"
|
||||
|
@ -19384,7 +19437,7 @@ multiparty@^4.2.1:
|
|||
safe-buffer "5.2.1"
|
||||
uid-safe "2.1.5"
|
||||
|
||||
mustache@^4.0.1:
|
||||
mustache@^4.0.1, mustache@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64"
|
||||
integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==
|
||||
|
@ -20608,6 +20661,21 @@ ora@^5.0.0, ora@^5.4.0, ora@^5.4.1:
|
|||
strip-ansi "^6.0.0"
|
||||
wcwidth "^1.0.1"
|
||||
|
||||
ora@^6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/ora/-/ora-6.1.0.tgz#86aa07058c4e9fb91444412d103b0d7e01aca973"
|
||||
integrity sha512-CxEP6845hLK+NHFWZ+LplGO4zfw4QSfxTlqMfvlJ988GoiUeZDMzCvqsZkFHv69sPICmJH1MDxZoQFOKXerAVw==
|
||||
dependencies:
|
||||
bl "^5.0.0"
|
||||
chalk "^5.0.0"
|
||||
cli-cursor "^4.0.0"
|
||||
cli-spinners "^2.6.1"
|
||||
is-interactive "^2.0.0"
|
||||
is-unicode-supported "^1.1.0"
|
||||
log-symbols "^5.1.0"
|
||||
strip-ansi "^7.0.1"
|
||||
wcwidth "^1.0.1"
|
||||
|
||||
original@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/original/-/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue