@storm-software/workspace-tools 1.269.0 → 1.270.0
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/CHANGELOG.md +52 -0
- package/README.md +2 -1
- package/dist/chunk-A7JGVU4P.js +468 -0
- package/dist/chunk-SRN4D7WO.mjs +468 -0
- package/dist/executors.js +2 -2
- package/dist/executors.mjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/src/executors/npm-publish/executor.js +2 -2
- package/dist/src/executors/npm-publish/executor.mjs +1 -1
- package/docs/executors/rollup.md +88 -0
- package/executors.ts +23 -0
- package/generators.ts +14 -0
- package/index.ts +5 -0
- package/package.json +4 -4
- package/project.json +58 -0
- package/src/base/base-executor.ts +200 -0
- package/src/base/base-executor.untyped.ts +18 -0
- package/src/base/base-generator.ts +130 -0
- package/src/base/base-generator.untyped.ts +16 -0
- package/src/base/cargo-base-executor.untyped.ts +73 -0
- package/src/base/index.ts +8 -0
- package/src/base/typescript-build-executor.untyped.ts +153 -0
- package/src/base/typescript-library-generator.ts +415 -0
- package/src/base/typescript-library-generator.untyped.ts +106 -0
- package/src/executors/cargo-build/executor.spec.ts +18 -0
- package/src/executors/cargo-build/executor.ts +28 -0
- package/src/executors/cargo-build/untyped.ts +18 -0
- package/src/executors/cargo-check/executor.spec.ts +18 -0
- package/src/executors/cargo-check/executor.ts +27 -0
- package/src/executors/cargo-check/untyped.ts +11 -0
- package/src/executors/cargo-clippy/executor.spec.ts +18 -0
- package/src/executors/cargo-clippy/executor.ts +28 -0
- package/src/executors/cargo-clippy/untyped.ts +18 -0
- package/src/executors/cargo-doc/executor.spec.ts +18 -0
- package/src/executors/cargo-doc/executor.ts +39 -0
- package/src/executors/cargo-doc/untyped.ts +44 -0
- package/src/executors/cargo-format/executor.spec.ts +18 -0
- package/src/executors/cargo-format/executor.ts +28 -0
- package/src/executors/cargo-format/untyped.ts +11 -0
- package/src/executors/cargo-publish/executor.spec.ts +11 -0
- package/src/executors/cargo-publish/executor.ts +139 -0
- package/src/executors/cargo-publish/untyped.ts +33 -0
- package/src/executors/clean-package/constants.ts +99 -0
- package/src/executors/clean-package/executor.spec.ts +18 -0
- package/src/executors/clean-package/executor.ts +214 -0
- package/src/executors/clean-package/types.ts +6 -0
- package/src/executors/clean-package/untyped.ts +60 -0
- package/src/executors/clean-package/utils.ts +85 -0
- package/src/executors/esbuild/executor.spec.ts +11 -0
- package/src/executors/esbuild/executor.ts +67 -0
- package/src/executors/esbuild/untyped.ts +20 -0
- package/src/executors/npm-publish/executor.spec.ts +11 -0
- package/src/executors/npm-publish/executor.ts +681 -0
- package/src/executors/npm-publish/untyped.ts +56 -0
- package/src/executors/size-limit/executor.spec.ts +18 -0
- package/src/executors/size-limit/executor.ts +88 -0
- package/src/executors/size-limit/untyped.ts +22 -0
- package/src/executors/typia/executor.ts +54 -0
- package/src/executors/typia/untyped.ts +48 -0
- package/src/executors/unbuild/executor.spec.ts +11 -0
- package/src/executors/unbuild/executor.ts +136 -0
- package/src/executors/unbuild/untyped.ts +152 -0
- package/src/generators/browser-library/generator.spec.ts +20 -0
- package/src/generators/browser-library/generator.ts +109 -0
- package/src/generators/browser-library/untyped.ts +29 -0
- package/src/generators/config-schema/generator.spec.ts +20 -0
- package/src/generators/config-schema/generator.ts +90 -0
- package/src/generators/config-schema/untyped.ts +19 -0
- package/src/generators/init/init.ts +32 -0
- package/src/generators/init/untyped.ts +16 -0
- package/src/generators/neutral-library/generator.spec.ts +20 -0
- package/src/generators/neutral-library/generator.ts +81 -0
- package/src/generators/neutral-library/untyped.ts +29 -0
- package/src/generators/node-library/generator.spec.ts +20 -0
- package/src/generators/node-library/generator.ts +84 -0
- package/src/generators/node-library/untyped.ts +29 -0
- package/src/generators/preset/files/.all-contributorsrc.template +48 -0
- package/src/generators/preset/files/.editorconfig +454 -0
- package/src/generators/preset/files/.env.template +38 -0
- package/src/generators/preset/files/.gitattributes +52 -0
- package/src/generators/preset/files/.github/.nvmrc +1 -0
- package/src/generators/preset/files/.github/CODEOWNERS +3 -0
- package/src/generators/preset/files/.github/CODE_OF_CONDUCT.md +125 -0
- package/src/generators/preset/files/.github/CONTRIBUTING.md.template +15 -0
- package/src/generators/preset/files/.github/FUNDING.yml +3 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/bug-report.yml.template +102 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/documentation.yml.template +56 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/feature-request.yml.template +60 -0
- package/src/generators/preset/files/.github/PULL_REQUEST_TEMPLATE.md.template +39 -0
- package/src/generators/preset/files/.github/SECURITY.md +9 -0
- package/src/generators/preset/files/.github/codecov.yml +29 -0
- package/src/generators/preset/files/.github/dependabot.yml +64 -0
- package/src/generators/preset/files/.github/labels.yml +84 -0
- package/src/generators/preset/files/.github/renovate.json +4 -0
- package/src/generators/preset/files/.github/renovate.json.template +63 -0
- package/src/generators/preset/files/.github/stale.yml +55 -0
- package/src/generators/preset/files/.github/workflows/build-release.yml.template +25 -0
- package/src/generators/preset/files/.github/workflows/code-review.yml +18 -0
- package/src/generators/preset/files/.github/workflows/codeql.yml +84 -0
- package/src/generators/preset/files/.github/workflows/dependabot-update.yml +32 -0
- package/src/generators/preset/files/.github/workflows/git-guardian.yml +23 -0
- package/src/generators/preset/files/.github/workflows/greetings.yml +31 -0
- package/src/generators/preset/files/.github/workflows/labels.yml +31 -0
- package/src/generators/preset/files/.github/workflows/lock.yml +26 -0
- package/src/generators/preset/files/.log4brains.yml.template +5 -0
- package/src/generators/preset/files/.markdownlint.json +155 -0
- package/src/generators/preset/files/.verdaccio/config.yml.template +40 -0
- package/src/generators/preset/files/.vscode/README.md +32 -0
- package/src/generators/preset/files/.vscode/cspell.json +3 -0
- package/src/generators/preset/files/.vscode/extensions.json +14 -0
- package/src/generators/preset/files/.vscode/launch.json +37 -0
- package/src/generators/preset/files/.vscode/settings.json +401 -0
- package/src/generators/preset/files/.vscode/tasks.json +4 -0
- package/src/generators/preset/files/.whitesource +14 -0
- package/src/generators/preset/files/assets/diagrams/.gitkeep +0 -0
- package/src/generators/preset/files/assets/icons/dark/.gitkeep +0 -0
- package/src/generators/preset/files/assets/icons/light/.gitkeep +0 -0
- package/src/generators/preset/files/assets/logos/.gitkeep +0 -0
- package/src/generators/preset/files/docs/api-reference/.gitkeep +0 -0
- package/src/generators/preset/generator.spec.ts +20 -0
- package/src/generators/preset/generator.ts +315 -0
- package/src/generators/preset/untyped.ts +88 -0
- package/src/generators/release-version/generator.spec.ts +20 -0
- package/src/generators/release-version/generator.ts +920 -0
- package/src/generators/release-version/untyped.ts +156 -0
- package/src/plugins/rust/cargo-toml.ts +434 -0
- package/src/plugins/rust/index.ts +1 -0
- package/src/plugins/typescript/index.ts +1 -0
- package/src/plugins/typescript/project-config.ts +564 -0
- package/src/plugins/typescript/tsup.ts +198 -0
- package/src/types.ts +130 -0
- package/src/utils/apply-workspace-tokens.ts +73 -0
- package/src/utils/cargo.ts +219 -0
- package/src/utils/create-cli-options.ts +23 -0
- package/src/utils/get-project-configurations.ts +27 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/lock-file.ts +159 -0
- package/src/utils/package-helpers.ts +54 -0
- package/src/utils/plugin-helpers.ts +112 -0
- package/src/utils/pnpm-deps-update.ts +111 -0
- package/src/utils/project-tags.ts +162 -0
- package/src/utils/toml.ts +204 -0
- package/src/utils/typia-transform.ts +8 -0
- package/src/utils/versions.ts +19 -0
- package/tsconfig.json +30 -0
- package/tsup.config.ts +36 -0
- package/dist/chunk-62LQXZNY.js +0 -282
- package/dist/chunk-F3VG4R53.mjs +0 -282
- package/dist/src/generators/preset/files/LICENSE +0 -201
- package/docs/api/base/base-executor.schema.md +0 -16
- package/docs/api/base/base-generator.schema.md +0 -15
- package/docs/api/base/cargo-base-executor.schema.md +0 -90
- package/docs/api/base/typescript-build-executor.schema.md +0 -126
- package/docs/api/base/typescript-library-generator.schema.md +0 -129
- package/docs/api/executors/cargo-build/schema.md +0 -89
- package/docs/api/executors/cargo-check/schema.md +0 -90
- package/docs/api/executors/cargo-clippy/schema.md +0 -99
- package/docs/api/executors/cargo-doc/schema.md +0 -130
- package/docs/api/executors/cargo-format/schema.md +0 -90
- package/docs/api/executors/cargo-publish/schema.md +0 -117
- package/docs/api/executors/clean-package/schema.md +0 -65
- package/docs/api/executors/esbuild/schema.md +0 -126
- package/docs/api/executors/npm-publish/schema.md +0 -64
- package/docs/api/executors/size-limit/schema.md +0 -25
- package/docs/api/executors/typia/schema.md +0 -46
- package/docs/api/executors/unbuild/schema.md +0 -222
- package/docs/api/generators/browser-library/files/README.md +0 -58
- package/docs/api/generators/browser-library/schema.md +0 -129
- package/docs/api/generators/config-schema/schema.md +0 -25
- package/docs/api/generators/init/schema.md +0 -15
- package/docs/api/generators/neutral-library/files/README.md +0 -58
- package/docs/api/generators/neutral-library/schema.md +0 -129
- package/docs/api/generators/node-library/files/README.md +0 -63
- package/docs/api/generators/node-library/schema.md +0 -129
- package/docs/api/generators/preset/schema.md +0 -110
- package/docs/api/generators/release-version/schema.md +0 -160
- /package/{dist/src → src}/base/base-executor.schema.d.ts +0 -0
- /package/{dist/src → src}/base/base-executor.schema.json +0 -0
- /package/{dist/src → src}/base/base-executor.schema.md +0 -0
- /package/{dist/src → src}/base/base-generator.schema.d.ts +0 -0
- /package/{dist/src → src}/base/base-generator.schema.json +0 -0
- /package/{dist/src → src}/base/base-generator.schema.md +0 -0
- /package/{dist/src → src}/base/cargo-base-executor.schema.d.ts +0 -0
- /package/{dist/src → src}/base/cargo-base-executor.schema.json +0 -0
- /package/{dist/src → src}/base/cargo-base-executor.schema.md +0 -0
- /package/{dist/src → src}/base/typescript-build-executor.schema.d.ts +0 -0
- /package/{dist/src → src}/base/typescript-build-executor.schema.json +0 -0
- /package/{dist/src → src}/base/typescript-build-executor.schema.md +0 -0
- /package/{dist/src → src}/base/typescript-library-generator.schema.d.ts +0 -0
- /package/{dist/src → src}/base/typescript-library-generator.schema.json +0 -0
- /package/{dist/src → src}/base/typescript-library-generator.schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-build/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-build/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-build/schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-check/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-check/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-check/schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-clippy/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-clippy/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-clippy/schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-doc/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-doc/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-doc/schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-format/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-format/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-format/schema.md +0 -0
- /package/{dist/src → src}/executors/cargo-publish/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/cargo-publish/schema.json +0 -0
- /package/{dist/src → src}/executors/cargo-publish/schema.md +0 -0
- /package/{dist/src → src}/executors/clean-package/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/clean-package/schema.json +0 -0
- /package/{dist/src → src}/executors/clean-package/schema.md +0 -0
- /package/{dist/src → src}/executors/esbuild/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/esbuild/schema.json +0 -0
- /package/{dist/src → src}/executors/esbuild/schema.md +0 -0
- /package/{dist/src → src}/executors/npm-publish/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/npm-publish/schema.json +0 -0
- /package/{dist/src → src}/executors/npm-publish/schema.md +0 -0
- /package/{dist/src → src}/executors/size-limit/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/size-limit/schema.json +0 -0
- /package/{dist/src → src}/executors/size-limit/schema.md +0 -0
- /package/{dist/src → src}/executors/typia/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/typia/schema.json +0 -0
- /package/{dist/src → src}/executors/typia/schema.md +0 -0
- /package/{dist/src → src}/executors/unbuild/schema.d.ts +0 -0
- /package/{dist/src → src}/executors/unbuild/schema.json +0 -0
- /package/{dist/src → src}/executors/unbuild/schema.md +0 -0
- /package/{dist/src → src}/generators/browser-library/files/README.md +0 -0
- /package/{dist/src → src}/generators/browser-library/files/jest.config.ts +0 -0
- /package/{dist/src → src}/generators/browser-library/files/src/index.ts.template +0 -0
- /package/{dist/src → src}/generators/browser-library/files/tsconfig.spec.json +0 -0
- /package/{dist/src → src}/generators/browser-library/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/browser-library/schema.json +0 -0
- /package/{dist/src → src}/generators/browser-library/schema.md +0 -0
- /package/{dist/src → src}/generators/config-schema/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/config-schema/schema.json +0 -0
- /package/{dist/src → src}/generators/config-schema/schema.md +0 -0
- /package/{dist/src → src}/generators/init/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/init/schema.json +0 -0
- /package/{dist/src → src}/generators/init/schema.md +0 -0
- /package/{dist/src → src}/generators/neutral-library/files/README.md +0 -0
- /package/{dist/src → src}/generators/neutral-library/files/jest.config.ts +0 -0
- /package/{dist/src → src}/generators/neutral-library/files/src/index.ts.template +0 -0
- /package/{dist/src → src}/generators/neutral-library/files/tsconfig.spec.json +0 -0
- /package/{dist/src → src}/generators/neutral-library/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/neutral-library/schema.json +0 -0
- /package/{dist/src → src}/generators/neutral-library/schema.md +0 -0
- /package/{dist/src → src}/generators/node-library/files/README.md +0 -0
- /package/{dist/src → src}/generators/node-library/files/jest.config.ts +0 -0
- /package/{dist/src → src}/generators/node-library/files/src/index.ts.template +0 -0
- /package/{dist/src → src}/generators/node-library/files/tsconfig.spec.json +0 -0
- /package/{dist/src → src}/generators/node-library/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/node-library/schema.json +0 -0
- /package/{dist/src → src}/generators/node-library/schema.md +0 -0
- /package/{LICENSE → src/generators/preset/files/LICENSE} +0 -0
- /package/{dist/src → src}/generators/preset/files/README.md.template +0 -0
- /package/{dist/src → src}/generators/preset/files/docs/readme-templates/README.footer.md.template +0 -0
- /package/{dist/src → src}/generators/preset/files/docs/readme-templates/README.header.md.template +0 -0
- /package/{dist/src → src}/generators/preset/files/eslint.config.js.template +0 -0
- /package/{dist/src → src}/generators/preset/files/knip.json +0 -0
- /package/{dist/src → src}/generators/preset/files/lefthook.json +0 -0
- /package/{dist/src → src}/generators/preset/files/nx.json +0 -0
- /package/{dist/src → src}/generators/preset/files/pnpm-workspace.yaml +0 -0
- /package/{dist/src → src}/generators/preset/files/socket.yaml +0 -0
- /package/{dist/src → src}/generators/preset/files/storm.json.template +0 -0
- /package/{dist/src → src}/generators/preset/files/tsconfig.base.json.template +0 -0
- /package/{dist/src → src}/generators/preset/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/preset/schema.json +0 -0
- /package/{dist/src → src}/generators/preset/schema.md +0 -0
- /package/{dist/src → src}/generators/release-version/schema.d.ts +0 -0
- /package/{dist/src → src}/generators/release-version/schema.json +0 -0
- /package/{dist/src → src}/generators/release-version/schema.md +0 -0
- /package/{dist/src → src}/plugins/typescript/untyped-schema.ts +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import type { ExecutorContext } from "@nx/devkit";
|
|
2
|
+
import { joinPathFragments } from "@nx/devkit";
|
|
3
|
+
import type { StormWorkspaceConfig } from "@storm-software/config";
|
|
4
|
+
import { writeInfo } from "@storm-software/config-tools/logger/console";
|
|
5
|
+
import { joinPaths } from "@storm-software/config-tools/utilities/correct-paths";
|
|
6
|
+
import {
|
|
7
|
+
copy,
|
|
8
|
+
mkdir,
|
|
9
|
+
pathExists,
|
|
10
|
+
readFile,
|
|
11
|
+
readJson,
|
|
12
|
+
remove,
|
|
13
|
+
writeFile,
|
|
14
|
+
writeJson
|
|
15
|
+
} from "fs-extra";
|
|
16
|
+
import { Glob } from "glob";
|
|
17
|
+
import { withRunExecutor } from "../../base/base-executor";
|
|
18
|
+
import { IGNORE_FIELDS, NPM_SCRIPTS, PUBLISH_CONFIG_FIELDS } from "./constants";
|
|
19
|
+
import { CleanPackageExecutorSchema } from "./schema.d";
|
|
20
|
+
import { PackageJson } from "./types";
|
|
21
|
+
import { createFilesFilter, filterObjectByKey, isObject } from "./utils";
|
|
22
|
+
|
|
23
|
+
export async function cleanPackageExecutorFn(
|
|
24
|
+
options: CleanPackageExecutorSchema,
|
|
25
|
+
context: ExecutorContext,
|
|
26
|
+
config: StormWorkspaceConfig
|
|
27
|
+
) {
|
|
28
|
+
const tempDirectoryName = joinPathFragments(
|
|
29
|
+
config.workspaceRoot,
|
|
30
|
+
"tmp",
|
|
31
|
+
context.root
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const exists = await pathExists(tempDirectoryName);
|
|
35
|
+
if (exists) {
|
|
36
|
+
writeInfo(
|
|
37
|
+
`🧹 Cleaning temporary directory path: ${tempDirectoryName}`,
|
|
38
|
+
config
|
|
39
|
+
);
|
|
40
|
+
await remove(tempDirectoryName);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await mkdir(tempDirectoryName);
|
|
44
|
+
writeInfo(`Created temporary directory: ${tempDirectoryName}`, config);
|
|
45
|
+
|
|
46
|
+
const packageJson = await readJson<PackageJson>(options.packageJsonPath);
|
|
47
|
+
|
|
48
|
+
await copy(options.outputPath, tempDirectoryName, {
|
|
49
|
+
filter: createFilesFilter(options.ignoredFiles, options.outputPath!)
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (options.cleanReadMe) {
|
|
53
|
+
await cleanReadMe(
|
|
54
|
+
tempDirectoryName,
|
|
55
|
+
packageJson.repository,
|
|
56
|
+
packageJson.homepage
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.cleanComments) {
|
|
61
|
+
await cleanComments(tempDirectoryName);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const tempPackageJson = clearPackageJSON(packageJson, options.fields);
|
|
65
|
+
writeJson(
|
|
66
|
+
joinPathFragments(tempDirectoryName, "package.json"),
|
|
67
|
+
tempPackageJson
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await copy(tempDirectoryName, options.outputPath, {
|
|
71
|
+
override: true,
|
|
72
|
+
preserveTimestamps: true
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await remove(tempDirectoryName);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
success: true
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getReadmeUrlFromRepository(repository: PackageJson["repository"]) {
|
|
83
|
+
const repoUrl = typeof repository === "object" ? repository.url : repository;
|
|
84
|
+
if (repoUrl) {
|
|
85
|
+
const name = repoUrl.match(/[^/:]+\/[^/:]+$/)?.[0]?.replace(/\.git$/, "");
|
|
86
|
+
return `https://github.com/${name}#README.md`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function cleanReadMe(
|
|
93
|
+
directoryName: string,
|
|
94
|
+
repository: PackageJson["repository"],
|
|
95
|
+
homepage: PackageJson["homepage"]
|
|
96
|
+
) {
|
|
97
|
+
const readmePath = joinPathFragments(directoryName, "README.md");
|
|
98
|
+
const readme = await readFile(readmePath);
|
|
99
|
+
const readmeUrl = getReadmeUrlFromRepository(repository);
|
|
100
|
+
if (homepage || readmeUrl) {
|
|
101
|
+
const cleaned =
|
|
102
|
+
readme.toString().split(/\n##\s*\w/m)[0] +
|
|
103
|
+
"\n## Documentation\n" +
|
|
104
|
+
`Read full docs **[here](${homepage || readmeUrl})**.\n`;
|
|
105
|
+
|
|
106
|
+
await writeFile(readmePath, cleaned);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function cleanComments(directoryName: string) {
|
|
111
|
+
const glob = new Glob(["**/*.js"], { cwd: directoryName });
|
|
112
|
+
|
|
113
|
+
const files = await glob.walk();
|
|
114
|
+
await Promise.all(
|
|
115
|
+
files.map(async i => {
|
|
116
|
+
const file = joinPathFragments(directoryName, i);
|
|
117
|
+
const content = await readFile(file);
|
|
118
|
+
const cleaned = content
|
|
119
|
+
.toString()
|
|
120
|
+
.replace(/\s*\/\/.*\n/gm, "\n")
|
|
121
|
+
.replace(/\s*\/\*[^/]+\*\/\n?/gm, "\n")
|
|
122
|
+
.replace(/\n+/gm, "\n")
|
|
123
|
+
.replace(/^\n+/gm, "");
|
|
124
|
+
|
|
125
|
+
await writeFile(file, cleaned);
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function clearPackageJSON(packageJson, inputIgnoreFields) {
|
|
131
|
+
const ignoreFields = inputIgnoreFields
|
|
132
|
+
? IGNORE_FIELDS.concat(inputIgnoreFields)
|
|
133
|
+
: IGNORE_FIELDS;
|
|
134
|
+
|
|
135
|
+
if (!packageJson.publishConfig) {
|
|
136
|
+
return packageJson;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const publishConfig = {
|
|
140
|
+
...packageJson.publishConfig
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
PUBLISH_CONFIG_FIELDS.forEach(field => {
|
|
144
|
+
if (publishConfig[field]) {
|
|
145
|
+
packageJson[field] = publishConfig[field];
|
|
146
|
+
delete publishConfig[field];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (!Object.keys(publishConfig).length) {
|
|
151
|
+
// delete property by destructuring
|
|
152
|
+
// eslint-disable-next-line no-unused-vars
|
|
153
|
+
const { publishConfig: _, ...pkg } = packageJson;
|
|
154
|
+
|
|
155
|
+
return pkg;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const cleanPackageJSON = filterObjectByKey(
|
|
159
|
+
{
|
|
160
|
+
...packageJson,
|
|
161
|
+
publishConfig
|
|
162
|
+
},
|
|
163
|
+
key => !!(key && !ignoreFields.includes(key) && key !== "scripts")
|
|
164
|
+
) as PackageJson;
|
|
165
|
+
|
|
166
|
+
if (packageJson.scripts && !ignoreFields.includes("scripts")) {
|
|
167
|
+
cleanPackageJSON.scripts = filterObjectByKey(
|
|
168
|
+
packageJson.scripts,
|
|
169
|
+
script => !!(script && NPM_SCRIPTS.includes(script))
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (
|
|
173
|
+
cleanPackageJSON.scripts.publish &&
|
|
174
|
+
/^clean-publish( |$)/.test(cleanPackageJSON.scripts.publish)
|
|
175
|
+
) {
|
|
176
|
+
// "custom" publish script is actually calling clean-publish
|
|
177
|
+
delete cleanPackageJSON.scripts.publish;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (const i in cleanPackageJSON) {
|
|
182
|
+
if (
|
|
183
|
+
isObject(cleanPackageJSON[i]) &&
|
|
184
|
+
Object.keys(cleanPackageJSON[i]).length === 0
|
|
185
|
+
) {
|
|
186
|
+
delete cleanPackageJSON[i];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return cleanPackageJSON;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default withRunExecutor<CleanPackageExecutorSchema>(
|
|
193
|
+
"Storm Clean-Package executor",
|
|
194
|
+
cleanPackageExecutorFn,
|
|
195
|
+
{
|
|
196
|
+
skipReadingConfig: false,
|
|
197
|
+
hooks: {
|
|
198
|
+
applyDefaultOptions: (
|
|
199
|
+
options: CleanPackageExecutorSchema
|
|
200
|
+
): CleanPackageExecutorSchema => {
|
|
201
|
+
options.outputPath ??= "dist/{projectRoot}";
|
|
202
|
+
options.packageJsonPath ??= joinPaths(
|
|
203
|
+
options.outputPath,
|
|
204
|
+
"package.json"
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
options.cleanReadMe ??= true;
|
|
208
|
+
options.cleanComments ??= true;
|
|
209
|
+
|
|
210
|
+
return options;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineUntypedSchema } from "untyped";
|
|
2
|
+
import baseExecutorSchema from "../../base/base-executor.untyped";
|
|
3
|
+
|
|
4
|
+
export default defineUntypedSchema({
|
|
5
|
+
...baseExecutorSchema,
|
|
6
|
+
$schema: {
|
|
7
|
+
id: "CleanPackageExecutorSchema",
|
|
8
|
+
title: "Clean Package Executor",
|
|
9
|
+
description:
|
|
10
|
+
"The clean package executor is responsible for removing unnecessary files and fields from a distributable package to make it as light as possible (for scenarios like edge computing, limited memory environments, etc.)",
|
|
11
|
+
},
|
|
12
|
+
outputPath: {
|
|
13
|
+
$schema: {
|
|
14
|
+
title: "Output Path",
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "The path to the output",
|
|
17
|
+
},
|
|
18
|
+
$default: "dist/{projectRoot}",
|
|
19
|
+
},
|
|
20
|
+
packageJsonPath: {
|
|
21
|
+
$schema: {
|
|
22
|
+
title: "Package JSON Path",
|
|
23
|
+
type: "string",
|
|
24
|
+
format: "path",
|
|
25
|
+
description: "The path to the package.json that will be modified",
|
|
26
|
+
},
|
|
27
|
+
$default: "{outputPath}/package.json",
|
|
28
|
+
},
|
|
29
|
+
ignoredFiles: {
|
|
30
|
+
$schema: {
|
|
31
|
+
title: "Ignored Files",
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The files to ignore",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
fields: {
|
|
37
|
+
$schema: {
|
|
38
|
+
title: "Fields",
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "The fields to include",
|
|
41
|
+
},
|
|
42
|
+
$resolve: (val: string[] = []) => ([] as string[]).concat(val),
|
|
43
|
+
},
|
|
44
|
+
cleanReadMe: {
|
|
45
|
+
$schema: {
|
|
46
|
+
title: "Clean Read Me",
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Clean the read me",
|
|
49
|
+
},
|
|
50
|
+
$default: true,
|
|
51
|
+
},
|
|
52
|
+
cleanComments: {
|
|
53
|
+
$schema: {
|
|
54
|
+
title: "Clean Comments",
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Clean the comments",
|
|
57
|
+
},
|
|
58
|
+
$default: true,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Glob, hasMagic } from "glob";
|
|
2
|
+
import micromatch from "micromatch";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import { IGNORE_FILES } from "./constants";
|
|
5
|
+
|
|
6
|
+
export function isObject(object) {
|
|
7
|
+
return Boolean(object) && typeof object === "object";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function filterObjectByKey(
|
|
11
|
+
object: Record<string, any>,
|
|
12
|
+
filterByKey = (key?: string) => true,
|
|
13
|
+
deep = false,
|
|
14
|
+
) {
|
|
15
|
+
const result = {};
|
|
16
|
+
let changed = false;
|
|
17
|
+
|
|
18
|
+
for (const key in object) {
|
|
19
|
+
if (filterByKey(key)) {
|
|
20
|
+
if (deep && isObject(object[key])) {
|
|
21
|
+
result[key] = filterObjectByKey(object[key], filterByKey, deep);
|
|
22
|
+
|
|
23
|
+
if (result[key] !== object[key]) {
|
|
24
|
+
changed = true;
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
result[key] = object[key];
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
changed = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return changed ? result : object;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createIgnoreMatcher(ignorePattern: string | RegExp = "**/*") {
|
|
38
|
+
if (ignorePattern instanceof RegExp) {
|
|
39
|
+
return (filename) => !ignorePattern.test(filename);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (hasMagic(ignorePattern, { magicalBraces: true })) {
|
|
43
|
+
const isMatch = micromatch.matcher(ignorePattern);
|
|
44
|
+
|
|
45
|
+
return (_filename, path) => !isMatch(path);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (filename) => filename !== ignorePattern;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function createFilesFilter(ignoreFiles = "", cwd: string) {
|
|
52
|
+
let ignoreFilesList = [] as string[];
|
|
53
|
+
|
|
54
|
+
if (ignoreFiles) {
|
|
55
|
+
const glob = new Glob(ignoreFiles, { cwd });
|
|
56
|
+
ignoreFilesList = await glob.walk();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const ignorePatterns =
|
|
60
|
+
ignoreFilesList.length > 0
|
|
61
|
+
? IGNORE_FILES.concat(...ignoreFilesList).filter(Boolean)
|
|
62
|
+
: IGNORE_FILES;
|
|
63
|
+
const filter = ignorePatterns.reduce(
|
|
64
|
+
(
|
|
65
|
+
next: null | ((filename: string, path: string) => void),
|
|
66
|
+
ignorePattern,
|
|
67
|
+
) => {
|
|
68
|
+
const ignoreMatcher = createIgnoreMatcher(ignorePattern);
|
|
69
|
+
|
|
70
|
+
if (!next) {
|
|
71
|
+
return ignoreMatcher;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (filename: string, path: string) =>
|
|
75
|
+
ignoreMatcher(filename, path) && next && next(filename, path);
|
|
76
|
+
},
|
|
77
|
+
null,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return (path) => {
|
|
81
|
+
const filename = basename(path);
|
|
82
|
+
|
|
83
|
+
return filter?.(filename, path);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import executor from "./executor";
|
|
2
|
+
import { RolldownExecutorSchema } from "./schema.d";
|
|
3
|
+
|
|
4
|
+
const options: RolldownExecutorSchema = {};
|
|
5
|
+
|
|
6
|
+
describe("Rolldown Executor", () => {
|
|
7
|
+
it("can run", async () => {
|
|
8
|
+
const output = await executor(options);
|
|
9
|
+
expect(output.success).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ExecutorContext } from "@nx/devkit";
|
|
2
|
+
import type { StormWorkspaceConfig } from "@storm-software/config";
|
|
3
|
+
import { writeInfo } from "@storm-software/config-tools/logger/console";
|
|
4
|
+
import { build, ESBuildOptions } from "@storm-software/esbuild";
|
|
5
|
+
import { withRunExecutor } from "../../base/base-executor";
|
|
6
|
+
import type { ESBuildExecutorSchema } from "./schema.d";
|
|
7
|
+
|
|
8
|
+
export async function esbuildExecutorFn(
|
|
9
|
+
options: ESBuildExecutorSchema,
|
|
10
|
+
context: ExecutorContext,
|
|
11
|
+
config?: StormWorkspaceConfig
|
|
12
|
+
) {
|
|
13
|
+
writeInfo("📦 Running Storm ESBuild executor on the workspace", config);
|
|
14
|
+
|
|
15
|
+
// #region Prepare build context variables
|
|
16
|
+
|
|
17
|
+
if (
|
|
18
|
+
!context.projectsConfigurations?.projects ||
|
|
19
|
+
!context.projectName ||
|
|
20
|
+
!context.projectsConfigurations.projects[context.projectName] ||
|
|
21
|
+
!context.projectsConfigurations.projects[context.projectName]?.root
|
|
22
|
+
) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// #endregion Prepare build context variables
|
|
29
|
+
|
|
30
|
+
await build({
|
|
31
|
+
...options,
|
|
32
|
+
projectRoot:
|
|
33
|
+
context.projectsConfigurations.projects?.[context.projectName]!.root,
|
|
34
|
+
name: context.projectName,
|
|
35
|
+
sourceRoot:
|
|
36
|
+
context.projectsConfigurations.projects?.[context.projectName]
|
|
37
|
+
?.sourceRoot,
|
|
38
|
+
format: options.format as ESBuildOptions["format"],
|
|
39
|
+
platform: options.format as ESBuildOptions["platform"]
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// #endregion Run the build process
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
success: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default withRunExecutor<ESBuildExecutorSchema>(
|
|
50
|
+
"Storm ESBuild build",
|
|
51
|
+
esbuildExecutorFn,
|
|
52
|
+
{
|
|
53
|
+
skipReadingConfig: false,
|
|
54
|
+
hooks: {
|
|
55
|
+
applyDefaultOptions: async (
|
|
56
|
+
options: ESBuildExecutorSchema,
|
|
57
|
+
config?: StormWorkspaceConfig | undefined
|
|
58
|
+
) => {
|
|
59
|
+
options.entry ??= ["src/index.ts"];
|
|
60
|
+
options.outputPath ??= "dist/{projectRoot}";
|
|
61
|
+
options.tsconfig ??= "{projectRoot}/tsconfig.json";
|
|
62
|
+
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineUntypedSchema } from "untyped";
|
|
2
|
+
import typescriptBuildExecutorSchema from "../../base/typescript-build-executor.untyped";
|
|
3
|
+
|
|
4
|
+
export default defineUntypedSchema({
|
|
5
|
+
...typescriptBuildExecutorSchema,
|
|
6
|
+
$schema: {
|
|
7
|
+
id: "ESBuildExecutorSchema",
|
|
8
|
+
title: "ESBuild Executor",
|
|
9
|
+
description: "A type definition for an ESBuild executor schema",
|
|
10
|
+
},
|
|
11
|
+
format: {
|
|
12
|
+
$schema: {
|
|
13
|
+
title: "Format",
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "The format to build",
|
|
16
|
+
enum: ["cjs", "esm", "iife"],
|
|
17
|
+
},
|
|
18
|
+
$default: "esm",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// import type { NpmPublishExecutorSchema } from "./schema.d";
|
|
2
|
+
// import executor from "./executor";
|
|
3
|
+
|
|
4
|
+
// const options: NpmPublishExecutorSchema = {};
|
|
5
|
+
|
|
6
|
+
// describe("NpmPublish Executor", () => {
|
|
7
|
+
// it("can run", async () => {
|
|
8
|
+
// const output = await executor(options);
|
|
9
|
+
// expect(output.success).toBe(true);
|
|
10
|
+
// });
|
|
11
|
+
// });
|