-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
6 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@spearwolf/twopoint5d", | ||
"description": "a 2.5d graphics library built on three.js", | ||
"description": "a library to create 2.5d realtime graphics and pixelart with three.js", | ||
"version": "0.0.0", | ||
"author": "Wolfger Schramm <[email protected]>", | ||
"license": "Apache-2.0", | ||
|
@@ -18,6 +18,7 @@ | |
"lint": "nx run-many -t lint", | ||
"test:affected": "nx affected -t test", | ||
"clean": "nx run-many -t clean && rimraf dist", | ||
"publishNpmPkg": "nx run-many -t publishNpmPkg", | ||
"update": "npx npm-check --update", | ||
"cbt": "run-s clean build test", | ||
"lookbook": "nx dev lookbook", | ||
|
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,8 @@ | ||
# @spearwolf/twopoint5d | ||
|
||
_a library to create 2.5d realtime graphics and pixelart with three.js_ | ||
|
||
please see :octocat: [spearwolf/twopoint5d](https://github.com/spearwolf/twopoint5d) for full details | ||
|
||
have fun! :rocket: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import {fileURLToPath} from 'node:url'; | ||
import {exec, execSync} from 'node:child_process'; | ||
|
||
const DRY_RUN = true || process.argv.includes('--dry-run'); | ||
|
||
const workspaceRoot = path.resolve(fileURLToPath(import.meta.url), '../../'); | ||
const projectRoot = path.resolve(process.cwd()); | ||
const packageRoot = path.resolve(projectRoot, process.argv[2]); | ||
const pkgJson = JSON.parse(fs.readFileSync(path.resolve(packageRoot, 'package.json'), 'utf8')); | ||
|
||
console.log('workspaceRoot:', workspaceRoot); | ||
console.log('projectRoot:', projectRoot); | ||
console.log('packageRoot:', packageRoot); | ||
console.log('packageJson: ---'); | ||
console.dir(pkgJson); | ||
|
||
if (pkgJson.version.endsWith('-dev')) { | ||
console.warn('skip publishing, version', pkgJson.version, 'is marked as a *development* version'); | ||
process.exit(0); | ||
} | ||
|
||
exec(`npm show ${pkgJson.name} versions --json`, (error, stdout, stderr) => { | ||
if (!error) { | ||
const versions = JSON.parse(stdout); | ||
console.log('already published versions: ---'); | ||
console.dir(versions); | ||
|
||
if (versions.includes(pkgJson.version)) { | ||
console.warn('skip publishing, version', pkgJson.version, 'is already released'); | ||
process.exit(0); | ||
} else { | ||
publishPackage(packageRoot); | ||
} | ||
} else if (stderr && stderr.toString().includes('npm ERR! code E404')) { | ||
console.log('oh it looks like this is the first time to publish the package'); | ||
publishPackage(packageRoot); | ||
} else { | ||
console.error(`exec() panic: ${stderr}`); | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
function publishPackage(cwd, dryRun = DRY_RUN) { | ||
copyFile(path.resolve(workspaceRoot, 'LICENSE'), path.resolve(cwd, 'LICENSE')); | ||
copyFile(path.resolve(projectRoot, 'CHANGELOG.md'), path.resolve(cwd, 'CHANGELOG.md')); | ||
|
||
const readmePkgPath = path.resolve(projectRoot, 'README-pkg.md'); | ||
const readmeDstPath = path.resolve(cwd, 'README.md'); | ||
if (fs.existsSync(readmePkgPath)) { | ||
copyFile(readmePkgPath, readmeDstPath); | ||
} else { | ||
copyFile(path.resolve(projectRoot, 'README.md'), readmeDstPath); | ||
} | ||
|
||
execSync(`npm publish --access public${dryRun ? ' --dry-run' : ''}`, {cwd}); | ||
|
||
process.exit(0); | ||
} | ||
|
||
function copyFile(src, dst) { | ||
if (fs.existsSync(src)) { | ||
fs.copyFileSync(src, dst); | ||
} | ||
} |