@storm-software/git-tools 2.125.4 → 2.126.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/bin/git.cjs +29 -5
- package/bin/git.cjs.map +1 -1
- package/bin/git.js +45 -21
- package/bin/git.js.map +1 -1
- package/dist/lefthook/recommended.yml +3 -7
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +5 -5
package/bin/git.js
CHANGED
|
@@ -26,13 +26,13 @@ import chalkTemplate from 'chalk-template';
|
|
|
26
26
|
import fs, { readFile as readFile$1, writeFile } from 'node:fs/promises';
|
|
27
27
|
import createBasePreset from 'conventional-changelog-conventionalcommits';
|
|
28
28
|
import { readCachedProjectGraph, createProjectGraphAsync as createProjectGraphAsync$1, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph$1 } from 'nx/src/project-graph/project-graph';
|
|
29
|
-
import { existsSync } from 'fs';
|
|
29
|
+
import { existsSync as existsSync$1 } from 'fs';
|
|
30
30
|
import { readFile } from 'fs/promises';
|
|
31
31
|
import childProcess, { execSync } from 'node:child_process';
|
|
32
32
|
import defaultRules from '@commitlint/rules';
|
|
33
33
|
import 'stream';
|
|
34
34
|
import util from 'node:util';
|
|
35
|
-
import { existsSync
|
|
35
|
+
import { existsSync, readFileSync, rmSync, readdirSync, writeFileSync, statSync, promises } from 'node:fs';
|
|
36
36
|
import wrap from 'word-wrap';
|
|
37
37
|
import Path, { join as join$1, extname } from 'node:path';
|
|
38
38
|
import { createProjectGraphAsync, readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph.js';
|
|
@@ -979,7 +979,7 @@ async function runCommitLint(workspaceConfig, options) {
|
|
|
979
979
|
workspaceConfig.workspaceRoot,
|
|
980
980
|
options.file || options.message || COMMIT_EDITMSG_PATH
|
|
981
981
|
);
|
|
982
|
-
if (existsSync(commitFile)) {
|
|
982
|
+
if (existsSync$1(commitFile)) {
|
|
983
983
|
commitMessage = (await readFile(commitFile, "utf8"))?.trim();
|
|
984
984
|
}
|
|
985
985
|
}
|
|
@@ -1233,7 +1233,7 @@ async function createState(workspaceConfig, configPath) {
|
|
|
1233
1233
|
if (project) {
|
|
1234
1234
|
let description = `${project.name} - ${project.root}`;
|
|
1235
1235
|
const packageJsonPath = joinPaths(project.root, "package.json");
|
|
1236
|
-
if (existsSync
|
|
1236
|
+
if (existsSync(packageJsonPath)) {
|
|
1237
1237
|
const packageJsonFile = await readFile$1(packageJsonPath, "utf8");
|
|
1238
1238
|
const packageJson = JSON.parse(packageJsonFile);
|
|
1239
1239
|
description = packageJson.description || description;
|
|
@@ -1707,7 +1707,7 @@ var getExecutorMarkdown = (_packageName, executorsJsonFile, executorsJson) => {
|
|
|
1707
1707
|
findFilePath(executorsJsonFile),
|
|
1708
1708
|
executor.schema
|
|
1709
1709
|
);
|
|
1710
|
-
if (existsSync
|
|
1710
|
+
if (existsSync(schemaJsonPath)) {
|
|
1711
1711
|
const schemaJson = JSON.parse(
|
|
1712
1712
|
readFileSync(schemaJsonPath, "utf8") ?? "{}"
|
|
1713
1713
|
);
|
|
@@ -1805,7 +1805,7 @@ var getGeneratorMarkdown = (packageName, generatorsJsonFile, generatorsJson) =>
|
|
|
1805
1805
|
findFilePath(generatorsJsonFile),
|
|
1806
1806
|
generator.schema
|
|
1807
1807
|
);
|
|
1808
|
-
if (existsSync
|
|
1808
|
+
if (existsSync(schemaJsonPath)) {
|
|
1809
1809
|
const schemaJson = JSON.parse(
|
|
1810
1810
|
readFileSync(schemaJsonPath, "utf8") ?? "{}"
|
|
1811
1811
|
);
|
|
@@ -1977,14 +1977,38 @@ var runReadme = async ({
|
|
|
1977
1977
|
project,
|
|
1978
1978
|
output: output3,
|
|
1979
1979
|
clean = true,
|
|
1980
|
-
prettier = true
|
|
1980
|
+
prettier = true,
|
|
1981
|
+
workspace = false
|
|
1981
1982
|
}) => {
|
|
1982
1983
|
const projectGraph = await createProjectGraphAsync({
|
|
1983
1984
|
exitOnError: true
|
|
1984
1985
|
});
|
|
1985
1986
|
const projectConfigs = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
1986
|
-
|
|
1987
|
-
|
|
1987
|
+
const workspaceRoot = findWorkspaceRootSafe(process.cwd());
|
|
1988
|
+
if (!workspaceRoot) {
|
|
1989
|
+
throw new Error(
|
|
1990
|
+
"Unable to find the workspace root. Please ensure you are running this command from within a workspace."
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
let resolvedProject = project;
|
|
1994
|
+
if (workspace) {
|
|
1995
|
+
if (!existsSync(join$1(workspaceRoot, "project.json"))) {
|
|
1996
|
+
throw new Error(
|
|
1997
|
+
`The \`workspace\` flag was provided to the \`storm-git readme\` command-line interface, but a project.json file could not be found at the workspace root (${workspaceRoot}). Please ensure you are running this command from the root of your workspace.`
|
|
1998
|
+
);
|
|
1999
|
+
}
|
|
2000
|
+
const projectJson = JSON.parse(
|
|
2001
|
+
readFileSync(join$1(workspaceRoot, "project.json"), "utf8") ?? "{}"
|
|
2002
|
+
);
|
|
2003
|
+
if (!projectJson?.name) {
|
|
2004
|
+
throw new Error(
|
|
2005
|
+
`The \`workspace\` flag was provided to the \`storm-git readme\` command-line interface, but a name field could not be found in the project.json file at the workspace root (${workspaceRoot}). Please ensure the project.json file at the workspace root contains a name field.`
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
2008
|
+
resolvedProject = projectJson.name;
|
|
2009
|
+
}
|
|
2010
|
+
if (resolvedProject) {
|
|
2011
|
+
await runProjectReadme(resolvedProject, {
|
|
1988
2012
|
templates,
|
|
1989
2013
|
output: output3,
|
|
1990
2014
|
clean,
|
|
@@ -2008,10 +2032,10 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
2008
2032
|
const projectConfigs = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
2009
2033
|
const project = projectConfigs.projects[projectName];
|
|
2010
2034
|
const inputFile = join$1(project?.root ?? "./", "README.md");
|
|
2011
|
-
if (existsSync
|
|
2035
|
+
if (existsSync(inputFile)) {
|
|
2012
2036
|
console.info(`Formatting ${projectName}'s README file at "${inputFile}"`);
|
|
2013
2037
|
const outputFilePath = output3 ? output3.includes("README.md") ? output3 : join$1(findFilePath(output3), "README.md") : inputFile;
|
|
2014
|
-
if (clean && existsSync
|
|
2038
|
+
if (clean && existsSync(outputFilePath)) {
|
|
2015
2039
|
if (outputFilePath === inputFile) {
|
|
2016
2040
|
console.warn(
|
|
2017
2041
|
"Skipping cleaning since output directory + file name is the same as input directory + file name."
|
|
@@ -2035,7 +2059,7 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
2035
2059
|
);
|
|
2036
2060
|
let packageName = projectName;
|
|
2037
2061
|
const packageJsonPath = join$1(findFilePath(inputFile), "package.json");
|
|
2038
|
-
if (existsSync
|
|
2062
|
+
if (existsSync(packageJsonPath)) {
|
|
2039
2063
|
const packageJson = JSON.parse(
|
|
2040
2064
|
readFileSync(packageJsonPath, "utf8") ?? "{}"
|
|
2041
2065
|
);
|
|
@@ -2052,7 +2076,7 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
2052
2076
|
}
|
|
2053
2077
|
if (newContent.includes("<!-- START executors -->")) {
|
|
2054
2078
|
const executorsJsonPath = join$1(findFilePath(inputFile), "executors.json");
|
|
2055
|
-
if (existsSync
|
|
2079
|
+
if (existsSync(executorsJsonPath)) {
|
|
2056
2080
|
const executorsJson = JSON.parse(
|
|
2057
2081
|
readFileSync(executorsJsonPath, "utf8") ?? "{}"
|
|
2058
2082
|
);
|
|
@@ -2071,7 +2095,7 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
2071
2095
|
findFilePath(inputFile),
|
|
2072
2096
|
"generators.json"
|
|
2073
2097
|
);
|
|
2074
|
-
if (existsSync
|
|
2098
|
+
if (existsSync(generatorsJsonPath)) {
|
|
2075
2099
|
const generatorsJson = JSON.parse(
|
|
2076
2100
|
readFileSync(generatorsJsonPath, "utf8") ?? "{}"
|
|
2077
2101
|
);
|
|
@@ -2563,7 +2587,7 @@ async function generateChangelogForProjects({
|
|
|
2563
2587
|
"CHANGELOG.md"
|
|
2564
2588
|
);
|
|
2565
2589
|
let currentContent;
|
|
2566
|
-
if (existsSync
|
|
2590
|
+
if (existsSync(filePath)) {
|
|
2567
2591
|
currentContent = await readFile$1(filePath, "utf8");
|
|
2568
2592
|
}
|
|
2569
2593
|
writeDebug(
|
|
@@ -2900,7 +2924,7 @@ async function resolveTokenData(hostname) {
|
|
|
2900
2924
|
"gh",
|
|
2901
2925
|
"hosts.yml"
|
|
2902
2926
|
);
|
|
2903
|
-
if (existsSync
|
|
2927
|
+
if (existsSync(ghCLIPath)) {
|
|
2904
2928
|
const yamlContents = await promises.readFile(ghCLIPath, "utf8");
|
|
2905
2929
|
const ghCLIConfig = parse(yamlContents);
|
|
2906
2930
|
if (ghCLIConfig[hostname]) {
|
|
@@ -3343,7 +3367,7 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3343
3367
|
*/
|
|
3344
3368
|
constructor(projectGraph, releaseConfig, ignoreNxJsonConfig, workspaceConfig) {
|
|
3345
3369
|
let nxJson;
|
|
3346
|
-
if (!ignoreNxJsonConfig && existsSync
|
|
3370
|
+
if (!ignoreNxJsonConfig && existsSync(joinPaths(workspaceConfig.workspaceRoot, "nx.json"))) {
|
|
3347
3371
|
nxJson = readNxJson();
|
|
3348
3372
|
}
|
|
3349
3373
|
const config5 = defu(
|
|
@@ -3834,12 +3858,12 @@ async function updatePackageManifests(projectsVersionData, config5) {
|
|
|
3834
3858
|
);
|
|
3835
3859
|
const packageJsonPath = joinPaths(projectRoot, "package.json");
|
|
3836
3860
|
const cargoTomlPath = joinPaths(projectRoot, "Cargo.toml");
|
|
3837
|
-
if (existsSync
|
|
3861
|
+
if (existsSync(packageJsonPath)) {
|
|
3838
3862
|
const packageJsonContent = await readFile$1(packageJsonPath, "utf8");
|
|
3839
3863
|
const packageJson = JSON.parse(packageJsonContent);
|
|
3840
3864
|
packageJson.version = versionData.newVersion;
|
|
3841
3865
|
await writeFile(packageJsonPath, JSON.stringify(packageJson));
|
|
3842
|
-
} else if (existsSync
|
|
3866
|
+
} else if (existsSync(cargoTomlPath)) {
|
|
3843
3867
|
const cargoToml = parseCargoToml(
|
|
3844
3868
|
await readFile$1(cargoTomlPath, "utf8")
|
|
3845
3869
|
);
|
|
@@ -3878,8 +3902,8 @@ function createProgram(config5) {
|
|
|
3878
3902
|
"./tools/readme-templates"
|
|
3879
3903
|
).option(
|
|
3880
3904
|
"--project <project>",
|
|
3881
|
-
"The specific project to generate a README.md file for"
|
|
3882
|
-
).option("--output <path>", "Where to output the generated README.md file").option(
|
|
3905
|
+
"The specific project to generate a README.md file for. Defaults to the workspace root README.md if not provided."
|
|
3906
|
+
).option("--workspace", "Run for the workspace root's README.md file").option("--output <path>", "Where to output the generated README.md file").option(
|
|
3883
3907
|
"--clean",
|
|
3884
3908
|
"Should the output README.md file be cleaned before generation",
|
|
3885
3909
|
true
|