-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from FriendlyCaptcha/ship-dist-folder
Publish from dist folder
- Loading branch information
Showing
6 changed files
with
51 additions
and
7 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
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,6 +1,11 @@ | ||
# changelog | ||
|
||
## 0.0.1 | ||
**Date**: 2023-TODO | ||
## 0.1.1 | ||
**Date**: 2023-12-12 | ||
|
||
* Library and built script files are no longer in the `dist` folder, so you can remove `/dist` from import/script paths. | ||
|
||
## 0.1.0 | ||
**Date**: 2023-12-08 | ||
|
||
Initial release. |
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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
"build/", | ||
"node_modules/", | ||
"temp/", | ||
".github/", | ||
|
||
"**/*.html", | ||
"**/*.md", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,34 @@ | ||
/*! | ||
* Copyright (c) Friendly Captcha GmbH 2023. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
import fs from "fs"; | ||
import filepath from "path"; | ||
|
||
// This script is run before publishing to npm, it copies some files into the dist folder and copies a slimmed down version of package.json | ||
// into that folder too, along with some readme files. This is so that we can only publish the contents of the dist folder to npm, that way | ||
// we don't have `/dist/` in any import paths. | ||
|
||
(() => { | ||
const source = fs.readFileSync("package.json").toString("utf-8"); | ||
const pkg = JSON.parse(source); | ||
delete pkg.scripts; | ||
delete pkg.devDependencies; | ||
delete pkg.files; | ||
delete pkg.ava; | ||
delete pkg.private; | ||
if (pkg.main.startsWith("dist/")) { | ||
pkg.main = pkg.main.slice(5); | ||
} | ||
|
||
const outFolder = "dist"; | ||
|
||
for (const file of ["LICENSE.md", "README.md", "CHANGELOG.md"]) { | ||
fs.copyFileSync(file, filepath.join(outFolder, file)); | ||
} | ||
|
||
fs.writeFileSync(filepath.join(outFolder, "/package.json"), Buffer.from(JSON.stringify(pkg, null, 2), "utf-8")); | ||
fs.writeFileSync(filepath.join(outFolder, "/version.txt"), Buffer.from(pkg.version, "utf-8")); // Useful for CI/CD tagging of version. | ||
})(); |