-
-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Bump Node version, remove
src
arg in build & watch, and m…
…isc housekeeping (#1753) * refactor: Drop rimraf for built-in fs.rm * refactor: Drop src argument in build & watch cmds * refactor: Extract info cmd from CLI entrypoint * refactor: Remove update-notifier * refactor: Switch from fs.promises to fs/promises * docs: Adding changeset
- Loading branch information
1 parent
4de8c5b
commit f6139b5
Showing
18 changed files
with
98 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'preact-cli': major | ||
--- | ||
|
||
Minimum supported Node version for `preact-cli` is now v14.14.0. Please upgrade if you are on an older version. | ||
|
||
`build` and `watch` commands will no longer take an optional `src` directory argument; if you want to change the source directory from the default (`./src`), please instead use the `--src` flag (i.e., `--src differentSrc`). | ||
|
||
Upon rebuild, the output directory will no longer be outright deleted; instead, it will be emptied. This has the benefit of better supporting containerized environments where specific directories are mounted. Emptying the directory, rather than deleting and recreating it, ensures a stable reference for those tools. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
const rimraf = require('rimraf'); | ||
const { resolve } = require('path'); | ||
const { promisify } = require('util'); | ||
const { readdir, rm } = require('fs/promises'); | ||
const { join, resolve } = require('path'); | ||
const runWebpack = require('../lib/webpack/run-webpack'); | ||
const { toBool } = require('../util'); | ||
|
||
exports.build = async function buildCommand(src, argv) { | ||
argv.src = src || argv.src; | ||
exports.build = async function buildCommand(argv) { | ||
// add `default:true`s, `--no-*` disables | ||
argv.prerender = toBool(argv.prerender); | ||
|
||
let cwd = resolve(argv.cwd); | ||
|
||
// Empties destination directory -- useful when mounted with Docker | ||
// or similar situations where it's preferable to avoid directory deletion | ||
let dest = resolve(cwd, argv.dest); | ||
try { | ||
await Promise.all( | ||
( | ||
await readdir(dest) | ||
).map(item => rm(join(dest, item), { recursive: true })) | ||
); | ||
} catch (e) { | ||
if (e.code != 'ENOENT') throw e; | ||
} | ||
|
||
// we explicitly set the path as `dotenv` otherwise uses | ||
// `process.cwd()` -- this would cause issues in environments | ||
// like mono-repos or our test suite subjects where project root | ||
// and the current directory differ. | ||
require('dotenv').config({ path: resolve(cwd, '.env') }); | ||
|
||
if (argv.clean === void 0) { | ||
let dest = resolve(cwd, argv.dest); | ||
await promisify(rimraf)(dest); | ||
} | ||
|
||
await runWebpack(argv, true); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const envinfo = require('envinfo'); | ||
|
||
exports.info = async function infoCommand() { | ||
const info = await envinfo.run({ | ||
System: ['OS', 'CPU'], | ||
Binaries: ['Node', 'Yarn', 'npm'], | ||
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], | ||
npmPackages: [ | ||
'preact', | ||
'preact-cli', | ||
'preact-router', | ||
'preact-render-to-string', | ||
], | ||
npmGlobalPackages: ['preact-cli'], | ||
}); | ||
|
||
process.stdout.write(`\nEnvironment Info:${info}\n`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.