mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Merge branch 'main' of https://github.com/garronej/ts-ci
This commit is contained in:
commit
ddf911f4b9
3 changed files with 15 additions and 33 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
<br>
|
<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
> 🗣️ Sorry, since a recent GitHub update you need to manually allow GitHub Action to push on your REPO.
|
> 🗣️ Since a recent GitHub update you need to manually allow GitHub Action to push on your repo.
|
||||||
> Fo this reason the inital setup will fail.
|
> Fo this reason the inital setup will fail.
|
||||||
> You need to enabled permission and re-run failed job: [see video](https://user-images.githubusercontent.com/6702424/213480604-0aac0ea7-487f-491d-94ae-df245b2c7ee8.mov)
|
> You need to enabled permission and re-run failed job: [see video](https://user-images.githubusercontent.com/6702424/213480604-0aac0ea7-487f-491d-94ae-df245b2c7ee8.mov)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,26 @@ 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";
|
||||||
|
|
||||||
const singletonDependencies = [
|
const singletonDependencies: string[] = [
|
||||||
//"react",
|
//"react",
|
||||||
//"@types/react",
|
//"@types/react"
|
||||||
];
|
];
|
||||||
|
|
||||||
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
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
pathJoin(rootDirPath, "dist", "package.json"),
|
pathJoin(rootDirPath, "dist", "package.json"),
|
||||||
Buffer.from(
|
Buffer.from(
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
(() => {
|
(() => {
|
||||||
const packageJsonParsed = JSON.parse(
|
const packageJsonParsed = JSON.parse(fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8"));
|
||||||
fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8")
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...packageJsonParsed,
|
...packageJsonParsed,
|
||||||
"main": packageJsonParsed["main"]?.replace(/^dist\//, ""),
|
"main": packageJsonParsed["main"]?.replace(/^dist\//, ""),
|
||||||
"types": packageJsonParsed["types"]?.replace(/^dist\//, ""),
|
"types": packageJsonParsed["types"]?.replace(/^dist\//, ""),
|
||||||
"module": packageJsonParsed["module"]?.replace(/^dist\//, ""),
|
"module": packageJsonParsed["module"]?.replace(/^dist\//, ""),
|
||||||
"bin": !("bin" in packageJsonParsed)
|
|
||||||
? undefined
|
|
||||||
: Object.fromEntries(
|
|
||||||
Object.entries<string>(packageJsonParsed["bin"]).map(([k, v]) => [
|
|
||||||
k,
|
|
||||||
v.replace(/^dist\//, "")
|
|
||||||
])
|
|
||||||
),
|
|
||||||
"exports": !("exports" in packageJsonParsed)
|
"exports": !("exports" in packageJsonParsed)
|
||||||
? undefined
|
? undefined
|
||||||
: Object.fromEntries(
|
: Object.fromEntries(
|
||||||
|
|
@ -52,7 +43,7 @@ const commonThirdPartyDeps = (() => {
|
||||||
// For example [ "@emotion" ] it's more convenient than
|
// For example [ "@emotion" ] it's more convenient than
|
||||||
// having to list every sub emotion packages (@emotion/css @emotion/utils ...)
|
// having to list every sub emotion packages (@emotion/css @emotion/utils ...)
|
||||||
// in singletonDependencies
|
// in singletonDependencies
|
||||||
const namespaceSingletonDependencies = [];
|
const namespaceSingletonDependencies: string[] = [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...namespaceSingletonDependencies
|
...namespaceSingletonDependencies
|
||||||
|
|
@ -66,17 +57,15 @@ const commonThirdPartyDeps = (() => {
|
||||||
];
|
];
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const yarnHomeDirPath = pathJoin(rootDirPath, ".yarn_home");
|
const yarnGlobalDirPath = pathJoin(rootDirPath, ".yarn_home");
|
||||||
|
|
||||||
fs.rmSync(yarnHomeDirPath, { "recursive": true, "force": true });
|
fs.rmSync(yarnGlobalDirPath, { "recursive": true, "force": true });
|
||||||
fs.mkdirSync(yarnHomeDirPath);
|
fs.mkdirSync(yarnGlobalDirPath);
|
||||||
|
|
||||||
const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
||||||
const { targetModuleName, cwd } = params;
|
const { targetModuleName, cwd } = params;
|
||||||
|
|
||||||
const cmd = ["yarn", "link", ...(targetModuleName !== undefined ? [targetModuleName] : [])].join(
|
const cmd = ["yarn", "link", ...(targetModuleName !== undefined ? [targetModuleName] : ["--no-bin-links"])].join(" ");
|
||||||
" "
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`$ cd ${pathRelative(rootDirPath, cwd) || "."} && ${cmd}`);
|
console.log(`$ cd ${pathRelative(rootDirPath, cwd) || "."} && ${cmd}`);
|
||||||
|
|
||||||
|
|
@ -84,7 +73,7 @@ const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
||||||
cwd,
|
cwd,
|
||||||
"env": {
|
"env": {
|
||||||
...process.env,
|
...process.env,
|
||||||
"HOME": yarnHomeDirPath
|
"HOME": yarnGlobalDirPath
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -125,13 +114,7 @@ commonThirdPartyDeps.forEach(commonThirdPartyDep => {
|
||||||
console.log(`${current}/${total} ${commonThirdPartyDep}`);
|
console.log(`${current}/${total} ${commonThirdPartyDep}`);
|
||||||
|
|
||||||
const localInstallPath = pathJoin(
|
const localInstallPath = pathJoin(
|
||||||
...[
|
...[rootDirPath, "node_modules", ...(commonThirdPartyDep.startsWith("@") ? commonThirdPartyDep.split("/") : [commonThirdPartyDep])]
|
||||||
rootDirPath,
|
|
||||||
"node_modules",
|
|
||||||
...(commonThirdPartyDep.startsWith("@")
|
|
||||||
? commonThirdPartyDep.split("/")
|
|
||||||
: [commonThirdPartyDep])
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
execYarnLink({ "cwd": localInstallPath });
|
execYarnLink({ "cwd": localInstallPath });
|
||||||
|
|
@ -153,9 +136,7 @@ execYarnLink({ "cwd": pathJoin(rootDirPath, "dist") });
|
||||||
testAppPaths.forEach(testAppPath =>
|
testAppPaths.forEach(testAppPath =>
|
||||||
execYarnLink({
|
execYarnLink({
|
||||||
"cwd": testAppPath,
|
"cwd": testAppPath,
|
||||||
"targetModuleName": JSON.parse(
|
"targetModuleName": JSON.parse(fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8"))["name"]
|
||||||
fs.readFileSync(pathJoin(rootDirPath, "package.json")).toString("utf8")
|
|
||||||
)["name"]
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"lib": ["es2015", "DOM"],
|
"lib": ["es2015", "DOM"],
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
// Do not change or the linkinkg cript will stop working
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"newLine": "LF",
|
"newLine": "LF",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue