mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Make the linking script work on windows
This commit is contained in:
parent
5bb1873852
commit
a6c22f9c8c
2 changed files with 29 additions and 64 deletions
25
.github/release.yaml
vendored
25
.github/release.yaml
vendored
|
|
@ -1,25 +0,0 @@
|
||||||
changelog:
|
|
||||||
exclude:
|
|
||||||
labels:
|
|
||||||
- ignore-for-release
|
|
||||||
authors:
|
|
||||||
- octocat
|
|
||||||
categories:
|
|
||||||
- title: Breaking Changes 🛠
|
|
||||||
labels:
|
|
||||||
- breaking
|
|
||||||
- title: Exciting New Features 🎉
|
|
||||||
labels:
|
|
||||||
- feature
|
|
||||||
- title: Fixes 🔧
|
|
||||||
labels:
|
|
||||||
- fix
|
|
||||||
- title: Documentation 🔧
|
|
||||||
labels:
|
|
||||||
- docs
|
|
||||||
- title: CI 👷
|
|
||||||
labels:
|
|
||||||
- ci
|
|
||||||
- title: Other Changes
|
|
||||||
labels:
|
|
||||||
- '*'
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
import { join as pathJoin, relative as pathRelative } from "path";
|
import { join as pathJoin, relative as pathRelative } from "path";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
import * as os from "os";
|
||||||
|
|
||||||
const singletonDependencies: string[] = [
|
const singletonDependencies: string[] = [
|
||||||
//"react",
|
//"react",
|
||||||
|
|
@ -10,44 +11,31 @@ const singletonDependencies: string[] = [
|
||||||
const rootDirPath = pathJoin(__dirname, "..");
|
const rootDirPath = pathJoin(__dirname, "..");
|
||||||
|
|
||||||
//NOTE: This is only required because of: https://github.com/garronej/ts-ci/blob/c0e207b9677523d4ec97fe672ddd72ccbb3c1cc4/README.md?plain=1#L54-L58
|
//NOTE: This is only required because of: https://github.com/garronej/ts-ci/blob/c0e207b9677523d4ec97fe672ddd72ccbb3c1cc4/README.md?plain=1#L54-L58
|
||||||
fs.writeFileSync(
|
//If you change the outDir in tsconfig.json you must update this block.
|
||||||
pathJoin(rootDirPath, "dist", "package.json"),
|
{
|
||||||
Buffer.from(
|
let modifiedPackageJsonContent = fs
|
||||||
JSON.stringify(
|
.readFileSync(pathJoin(rootDirPath, "package.json"))
|
||||||
(() => {
|
.toString("utf8");
|
||||||
const packageJsonParsed = JSON.parse(
|
|
||||||
fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8")
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
modifiedPackageJsonContent = (() => {
|
||||||
...packageJsonParsed,
|
const o = JSON.parse(modifiedPackageJsonContent);
|
||||||
"main": packageJsonParsed["main"]?.replace(/^dist\//, ""),
|
|
||||||
"types": packageJsonParsed["types"]?.replace(/^dist\//, ""),
|
delete o.files;
|
||||||
"module": packageJsonParsed["module"]?.replace(/^dist\//, ""),
|
|
||||||
"bin": !("bin" in packageJsonParsed)
|
return JSON.stringify(o, null, 2);
|
||||||
? undefined
|
})();
|
||||||
: Object.fromEntries(
|
|
||||||
Object.entries(packageJsonParsed["bin"]).map(([key, value]) => [
|
modifiedPackageJsonContent = modifiedPackageJsonContent
|
||||||
key,
|
.replace(/"dist\//g, '"')
|
||||||
(value as string).replace(/^dist\//, "")
|
.replace(/"\.\/dist\//g, '"./')
|
||||||
])
|
.replace(/"!dist\//g, '"!')
|
||||||
),
|
.replace(/"!\.\/dist\//g, '"!./');
|
||||||
"exports": !("exports" in packageJsonParsed)
|
|
||||||
? undefined
|
fs.writeFileSync(
|
||||||
: Object.fromEntries(
|
pathJoin(rootDirPath, "dist", "package.json"),
|
||||||
Object.entries(packageJsonParsed["exports"]).map(([key, value]) => [
|
Buffer.from(modifiedPackageJsonContent, "utf8")
|
||||||
key,
|
);
|
||||||
(value as string).replace(/^\.\/dist\//, "./")
|
}
|
||||||
])
|
|
||||||
)
|
|
||||||
};
|
|
||||||
})(),
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
),
|
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const commonThirdPartyDeps = (() => {
|
const commonThirdPartyDeps = (() => {
|
||||||
// For example [ "@emotion" ] it's more convenient than
|
// For example [ "@emotion" ] it's more convenient than
|
||||||
|
|
@ -85,9 +73,11 @@ const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
||||||
|
|
||||||
execSync(cmd, {
|
execSync(cmd, {
|
||||||
cwd,
|
cwd,
|
||||||
"env": {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
"HOME": yarnGlobalDirPath
|
...(os.platform() === "win32"
|
||||||
|
? { USERPROFILE: yarnGlobalDirPath }
|
||||||
|
: { HOME: yarnGlobalDirPath })
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue