@vnejs/monorepo 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +21 -0
- package/src/cli.js +62 -0
- package/src/index.js +7 -0
- package/src/layers/helpers.js +26 -0
- package/src/layers/list-package-dirs.js +9 -0
- package/src/layers/uis.js +39 -0
- package/src/package/index.js +21 -0
- package/src/publish/index.js +47 -0
- package/src/publish/utils.js +38 -0
- package/src/publish-configs/index.js +38 -0
- package/src/publish-helpers/index.js +36 -0
- package/src/publish-uis/index.js +36 -0
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/monorepo",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Monorepo tooling for @vnejs",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"@vnejs/monorepo": "./src/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
12
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
13
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
14
|
+
},
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"commander": "~15.0.0",
|
|
19
|
+
"typescript": "6.0.3"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require("commander");
|
|
4
|
+
|
|
5
|
+
const packageJson = require("../package.json");
|
|
6
|
+
const publishAction = require("./publish");
|
|
7
|
+
const publishUisAction = require("./publish-uis");
|
|
8
|
+
const publishHelpersAction = require("./publish-helpers");
|
|
9
|
+
const publishConfigsAction = require("./publish-configs");
|
|
10
|
+
|
|
11
|
+
const program = new Command();
|
|
12
|
+
|
|
13
|
+
program.name(packageJson.name).description(packageJson.description).version(packageJson.version);
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.command("package")
|
|
17
|
+
.description("build TypeScript package in current directory")
|
|
18
|
+
.option("-c, --clean", "remove dist before build", false)
|
|
19
|
+
.option("--config <path>", "tsconfig path", "tsconfig.json")
|
|
20
|
+
.action((options) => require("./package")(options));
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.command("publish")
|
|
24
|
+
.description("Clean-build and publish package in current directory")
|
|
25
|
+
.argument("[bump]", "major | minor | patch | premajor | preminor | prepatch | prerelease | x.y.z")
|
|
26
|
+
.option("--access <access>", "npm publish --access", "public")
|
|
27
|
+
.option("--dry-run", "npm publish --dry-run (version is restored after success)", false)
|
|
28
|
+
.option("--otp <otp>", "npm publish --otp (only if your npm auth requires it)")
|
|
29
|
+
.option("--tag <tag>", "npm publish --tag", "latest")
|
|
30
|
+
.action(publishAction);
|
|
31
|
+
|
|
32
|
+
program
|
|
33
|
+
.command("publish-uis")
|
|
34
|
+
.description("Publish all uis workspace packages in dependency order")
|
|
35
|
+
.argument("<bump>", "major | minor | patch")
|
|
36
|
+
.option("--access <access>", "npm publish --access", "public")
|
|
37
|
+
.option("--dry-run", "npm publish --dry-run", false)
|
|
38
|
+
.option("--otp <otp>", "npm publish --otp")
|
|
39
|
+
.option("--tag <tag>", "npm publish --tag", "latest")
|
|
40
|
+
.action(publishUisAction);
|
|
41
|
+
|
|
42
|
+
program
|
|
43
|
+
.command("publish-helpers")
|
|
44
|
+
.description("Publish all helpers workspace packages in dependency order")
|
|
45
|
+
.argument("<bump>", "major | minor | patch")
|
|
46
|
+
.option("--access <access>", "npm publish --access", "public")
|
|
47
|
+
.option("--dry-run", "npm publish --dry-run", false)
|
|
48
|
+
.option("--otp <otp>", "npm publish --otp")
|
|
49
|
+
.option("--tag <tag>", "npm publish --tag", "latest")
|
|
50
|
+
.action(publishHelpersAction);
|
|
51
|
+
|
|
52
|
+
program
|
|
53
|
+
.command("publish-configs")
|
|
54
|
+
.description("Publish all configs workspace packages in dependency order")
|
|
55
|
+
.argument("<bump>", "major | minor | patch")
|
|
56
|
+
.option("--access <access>", "npm publish --access", "public")
|
|
57
|
+
.option("--dry-run", "npm publish --dry-run", false)
|
|
58
|
+
.option("--otp <otp>", "npm publish --otp")
|
|
59
|
+
.option("--tag <tag>", "npm publish --tag", "latest")
|
|
60
|
+
.action(publishConfigsAction);
|
|
61
|
+
|
|
62
|
+
program.parse();
|
package/src/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const listPackageDirs = require("./list-package-dirs");
|
|
4
|
+
|
|
5
|
+
module.exports = (root) => {
|
|
6
|
+
const helpersRoot = path.join(root, "helpers");
|
|
7
|
+
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
turboFilter: "./helpers/primitives/*",
|
|
11
|
+
packageDirs: listPackageDirs(path.join(helpersRoot, "primitives")),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
turboFilter: "./helpers/composites/*",
|
|
15
|
+
packageDirs: listPackageDirs(path.join(helpersRoot, "composites")),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
turboFilter: "./helpers/base",
|
|
19
|
+
packageDirs: [path.join(helpersRoot, "base")],
|
|
20
|
+
only: true,
|
|
21
|
+
},
|
|
22
|
+
].map((layer) => ({
|
|
23
|
+
...layer,
|
|
24
|
+
packageDirs: layer.packageDirs.filter((pkgDir) => existsSync(pkgDir)),
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const { existsSync, readdirSync } = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = (dir) =>
|
|
5
|
+
readdirSync(dir, { withFileTypes: true })
|
|
6
|
+
.filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist")
|
|
7
|
+
.map((entry) => path.join(dir, entry.name))
|
|
8
|
+
.filter((full) => existsSync(path.join(full, "package.json")))
|
|
9
|
+
.sort();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const listPackageDirs = require("./list-package-dirs");
|
|
4
|
+
|
|
5
|
+
module.exports = (root) => {
|
|
6
|
+
const uisRoot = path.join(root, "uis");
|
|
7
|
+
|
|
8
|
+
return [
|
|
9
|
+
{ turboFilter: "./uis/utils", packageDirs: [path.join(uisRoot, "utils")] },
|
|
10
|
+
{
|
|
11
|
+
turboFilter: "./uis/react/hooks/*",
|
|
12
|
+
packageDirs: listPackageDirs(path.join(uisRoot, "react/hooks")),
|
|
13
|
+
only: true,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
turboFilter: "./uis/react/primitives/*",
|
|
17
|
+
packageDirs: listPackageDirs(path.join(uisRoot, "react/primitives")),
|
|
18
|
+
only: true,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
turboFilter: "./uis/react/composites/*",
|
|
22
|
+
packageDirs: listPackageDirs(path.join(uisRoot, "react/composites")),
|
|
23
|
+
only: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
turboFilter: "./uis/react/complex/*",
|
|
27
|
+
packageDirs: listPackageDirs(path.join(uisRoot, "react/complex")),
|
|
28
|
+
only: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
turboFilter: "./uis/react/base",
|
|
32
|
+
packageDirs: [path.join(uisRoot, "react/base")],
|
|
33
|
+
only: true,
|
|
34
|
+
},
|
|
35
|
+
].map((layer) => ({
|
|
36
|
+
...layer,
|
|
37
|
+
packageDirs: layer.packageDirs.filter((pkgDir) => existsSync(pkgDir)),
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
module.exports = (options = {}) => {
|
|
6
|
+
const pkgDir = options.cwd || process.cwd();
|
|
7
|
+
const config = options.config || "tsconfig.json";
|
|
8
|
+
const configPath = path.join(pkgDir, config);
|
|
9
|
+
|
|
10
|
+
if (!existsSync(configPath)) {
|
|
11
|
+
console.error(`tsconfig not found: ${configPath}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (options.clean) {
|
|
16
|
+
execSync("rm -rf dist", { cwd: pkgDir, stdio: "inherit" });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const tsc = require.resolve("typescript/bin/tsc");
|
|
20
|
+
execSync(`node "${tsc}" -p "${config}"`, { cwd: pkgDir, stdio: "inherit" });
|
|
21
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { existsSync } = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const { readPackageName, readVersion, run, writeVersion, prepareForPublish } = require("./utils");
|
|
5
|
+
|
|
6
|
+
module.exports = async (bump, options = {}) => {
|
|
7
|
+
const pkgDir = process.cwd();
|
|
8
|
+
|
|
9
|
+
if (!existsSync(path.join(pkgDir, "package.json"))) {
|
|
10
|
+
console.error("package.json not found in current directory");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const packageName = readPackageName(pkgDir);
|
|
15
|
+
const oldVersion = readVersion(pkgDir);
|
|
16
|
+
const isDryRun = Boolean(options.dryRun);
|
|
17
|
+
const pkgLabel = packageName ? ` ${packageName}` : "";
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
if (bump) run(`npm version ${bump} --no-git-tag-version --no-workspaces-update`, pkgDir);
|
|
21
|
+
|
|
22
|
+
prepareForPublish(pkgDir);
|
|
23
|
+
|
|
24
|
+
const publishArgs = ["npm", "publish"];
|
|
25
|
+
|
|
26
|
+
if (options.access) publishArgs.push("--access", options.access);
|
|
27
|
+
if (isDryRun) publishArgs.push("--dry-run");
|
|
28
|
+
if (options.otp) publishArgs.push("--otp", options.otp);
|
|
29
|
+
if (options.tag && options.tag !== "latest") publishArgs.push("--tag", options.tag);
|
|
30
|
+
|
|
31
|
+
run(publishArgs.join(" "), pkgDir);
|
|
32
|
+
|
|
33
|
+
const publishedVersion = readVersion(pkgDir);
|
|
34
|
+
|
|
35
|
+
if (isDryRun) {
|
|
36
|
+
if (bump) writeVersion(pkgDir, oldVersion);
|
|
37
|
+
console.log(bump ? `Dry run ok. Version restored: ${oldVersion}` : `Dry run ok. Version unchanged: ${publishedVersion}`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(`Пакет ${pkgLabel} успешно опубликован с версией ${publishedVersion}`);
|
|
42
|
+
} catch {
|
|
43
|
+
if (bump && readVersion(pkgDir) !== oldVersion) writeVersion(pkgDir, oldVersion);
|
|
44
|
+
console.error(`Не удалось опубликовать пакет${pkgLabel}. Версия не была изменена (${oldVersion}).`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { existsSync, readFileSync, writeFileSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const readPackageJson = (pkgDir) => JSON.parse(readFileSync(path.join(pkgDir, "package.json"), "utf8"));
|
|
6
|
+
|
|
7
|
+
const readVersion = (pkgDir) => readPackageJson(pkgDir).version;
|
|
8
|
+
|
|
9
|
+
const readPackageName = (pkgDir) => readPackageJson(pkgDir).name;
|
|
10
|
+
|
|
11
|
+
const writeVersion = (pkgDir, version) => {
|
|
12
|
+
const pkgPath = path.join(pkgDir, "package.json");
|
|
13
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
14
|
+
|
|
15
|
+
pkg.version = version;
|
|
16
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
17
|
+
|
|
18
|
+
const lockPath = path.join(pkgDir, "package-lock.json");
|
|
19
|
+
if (!existsSync(lockPath)) return;
|
|
20
|
+
|
|
21
|
+
const lock = JSON.parse(readFileSync(lockPath, "utf8"));
|
|
22
|
+
if (lock.version) lock.version = version;
|
|
23
|
+
if (lock.packages?.[""]?.version) lock.packages[""].version = version;
|
|
24
|
+
writeFileSync(lockPath, JSON.stringify(lock, null, 2) + "\n");
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const run = (command, pkgDir) => {
|
|
28
|
+
execSync(command, { cwd: pkgDir, stdio: "inherit" });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const prepareForPublish = (pkgDir) => {
|
|
32
|
+
const pkg = readPackageJson(pkgDir);
|
|
33
|
+
if (!pkg.scripts?.build) return;
|
|
34
|
+
|
|
35
|
+
run("npx @vnejs/monorepo package --clean", pkgDir);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = { readPackageName, readVersion, writeVersion, run, prepareForPublish };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
module.exports = (bump, options = {}) => {
|
|
6
|
+
if (!["major", "minor", "patch"].includes(bump)) {
|
|
7
|
+
console.error("bump must be major, minor, or patch");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const root = process.cwd();
|
|
12
|
+
const configsRoot = path.join(root, "configs");
|
|
13
|
+
|
|
14
|
+
if (!existsSync(configsRoot)) {
|
|
15
|
+
console.error(`configs directory not found: ${configsRoot}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const packageDirs = [
|
|
20
|
+
path.join(configsRoot, "ts-common"),
|
|
21
|
+
path.join(configsRoot, "ts-uis"),
|
|
22
|
+
].filter((pkgDir) => existsSync(pkgDir));
|
|
23
|
+
|
|
24
|
+
const access = options.access || "public";
|
|
25
|
+
const publishArgs = [`npx @vnejs/monorepo publish ${bump}`, `--access ${access}`];
|
|
26
|
+
if (options.dryRun) publishArgs.push("--dry-run");
|
|
27
|
+
if (options.otp) publishArgs.push(`--otp ${options.otp}`);
|
|
28
|
+
if (options.tag && options.tag !== "latest") publishArgs.push(`--tag ${options.tag}`);
|
|
29
|
+
|
|
30
|
+
const command = publishArgs.join(" ");
|
|
31
|
+
|
|
32
|
+
for (const pkgDir of packageDirs) {
|
|
33
|
+
console.log(`\n==> ${path.relative(root, pkgDir)}`);
|
|
34
|
+
execSync(command, { cwd: pkgDir, stdio: "inherit" });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(`\nPublished ${packageDirs.length} configs packages (${bump}).`);
|
|
38
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const getHelpersLayers = require("../layers/helpers");
|
|
5
|
+
|
|
6
|
+
module.exports = (bump, options = {}) => {
|
|
7
|
+
if (!["major", "minor", "patch"].includes(bump)) {
|
|
8
|
+
console.error("bump must be major, minor, or patch");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const root = process.cwd();
|
|
13
|
+
const helpersRoot = path.join(root, "helpers");
|
|
14
|
+
|
|
15
|
+
if (!existsSync(helpersRoot)) {
|
|
16
|
+
console.error(`helpers directory not found: ${helpersRoot}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const packageDirs = getHelpersLayers(root).flatMap((layer) => layer.packageDirs);
|
|
21
|
+
|
|
22
|
+
const access = options.access || "public";
|
|
23
|
+
const publishArgs = [`npx @vnejs/monorepo publish ${bump}`, `--access ${access}`];
|
|
24
|
+
if (options.dryRun) publishArgs.push("--dry-run");
|
|
25
|
+
if (options.otp) publishArgs.push(`--otp ${options.otp}`);
|
|
26
|
+
if (options.tag && options.tag !== "latest") publishArgs.push(`--tag ${options.tag}`);
|
|
27
|
+
|
|
28
|
+
const command = publishArgs.join(" ");
|
|
29
|
+
|
|
30
|
+
for (const pkgDir of packageDirs) {
|
|
31
|
+
console.log(`\n==> ${path.relative(root, pkgDir)}`);
|
|
32
|
+
execSync(command, { cwd: pkgDir, stdio: "inherit" });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log(`\nPublished ${packageDirs.length} helpers packages (${bump}).`);
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { existsSync } = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const getUisLayers = require("../layers/uis");
|
|
5
|
+
|
|
6
|
+
module.exports = (bump, options = {}) => {
|
|
7
|
+
if (!["major", "minor", "patch"].includes(bump)) {
|
|
8
|
+
console.error("bump must be major, minor, or patch");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const root = process.cwd();
|
|
13
|
+
const uisRoot = path.join(root, "uis");
|
|
14
|
+
|
|
15
|
+
if (!existsSync(uisRoot)) {
|
|
16
|
+
console.error(`uis directory not found: ${uisRoot}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const packageDirs = getUisLayers(root).flatMap((layer) => layer.packageDirs);
|
|
21
|
+
|
|
22
|
+
const access = options.access || "public";
|
|
23
|
+
const publishArgs = [`npx @vnejs/monorepo publish ${bump}`, `--access ${access}`];
|
|
24
|
+
if (options.dryRun) publishArgs.push("--dry-run");
|
|
25
|
+
if (options.otp) publishArgs.push(`--otp ${options.otp}`);
|
|
26
|
+
if (options.tag && options.tag !== "latest") publishArgs.push(`--tag ${options.tag}`);
|
|
27
|
+
|
|
28
|
+
const command = publishArgs.join(" ");
|
|
29
|
+
|
|
30
|
+
for (const pkgDir of packageDirs) {
|
|
31
|
+
console.log(`\n==> ${path.relative(root, pkgDir)}`);
|
|
32
|
+
execSync(command, { cwd: pkgDir, stdio: "inherit" });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log(`\nPublished ${packageDirs.length} uis packages (${bump}).`);
|
|
36
|
+
};
|