Skip to content

Commit

Permalink
fix: tsconfig for library
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganitzsh committed Nov 9, 2023
1 parent 5b8284d commit b7b43f6
Show file tree
Hide file tree
Showing 30 changed files with 220 additions and 100 deletions.
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { Config, Options, Result } from 'semantic-release';
export declare const release: (overrideOptions?: Options, overrideConfig?: Config) => Promise<Result>;
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions dist/utilities/error.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Helper function to help the message part of the type Error
*/
export declare const getSetFailedErrorString: (messageOrError: unknown) => string;
//# sourceMappingURL=error.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/error.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/utilities/generatePlugins.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PluginSpec } from 'semantic-release';
import type { ReleaseRule } from './inputProcessors.js';
export declare const generatePlugins: ({ commitAssets, disableChangeLog, isNodeModule, releaseAssets, releaseRules, }: {
commitAssets: string[];
disableChangeLog?: boolean | undefined;
isNodeModule: boolean;
releaseAssets: string[];
releaseRules: ReleaseRule[];
}) => PluginSpec[];
//# sourceMappingURL=generatePlugins.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/generatePlugins.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions dist/utilities/git.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Options } from 'execa';
/**
* Initialize local `remote` git repository in a temporary temporaryDirectory.
*/
export declare const initGitRemote: () => Promise<{
cwd: string;
remoteRepositoryUrl: string;
}>;
/**
* Create a shallow clone of a git repository. The shallow will contain a
* limited number of commit and no tags.
*/
export declare const gitShallowClone: (repositoryUrl: string, depth?: number) => Promise<string>;
/**
* Create commits on the git repository present in the `cwd` option.
*/
export declare const gitCommits: (messages: string[], execaOptions: Options) => Promise<void>;
/**
* Create a tag on the head commit on the git repository present in the `cwd`
* option.
*/
export declare const gitTagVersion: (tagName: string, execaOptions: Options) => Promise<void>;
/**
* Creates a temporary git remote repository and a git clone repository.
*/
export declare const gitRepo: () => Promise<{
cwd: string;
repositoryUrl: string;
}>;
/**
* Push to the remote repository from the git repository present in the `cwd`
* option.
*/
export declare const gitPush: (repositoryUrl: string, branch: string, execaOptions: Options) => Promise<void>;
//# sourceMappingURL=git.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/git.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions dist/utilities/inputProcessors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { BranchSpec } from 'semantic-release';
export interface AdditionalPluginsSpec {
[plugin: string]: string;
}
export declare enum InputParameters {
AdditionalPlugins = "additional-plugins",
CommitAssets = "commit-assets",
ConfigFile = "config-file",
DisableChangelog = "disable-changelog",
DryRun = "dry-run",
NodeModule = "node-module",
ReleaseAssets = "release-assets",
ReleaseBranches = "release-branches",
ReleaseRules = "release-rules",
ReleaseRulesAppend = "release-rules-append"
}
export interface ReleaseRule {
release: string | false;
scope?: string;
subject?: string;
type?: string;
}
/**
* These rules extend the default rules provided by commit-analyzer.
* Added rules are types supported by commitizen but not supported in standard
* commit-analyzer. Rules are based on Angular contribution guidelines:
* https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular#type
*/
export declare const DEFAULT_RELEASE_RULES: ReleaseRule[];
export declare const processInputAdditionalPlugins: () => AdditionalPluginsSpec | undefined;
export declare const processInputNodeModule: () => boolean;
export declare const processInputDisableChangelog: () => boolean;
export declare const processInputDryRun: () => boolean;
export declare const processInputReleaseBranches: () => BranchSpec[] | undefined;
export declare const processInputConfigFile: () => string | undefined;
export declare const processInputReleaseRules: () => ReleaseRule[];
export declare const processInputCommitAssets: () => string[];
export declare const processInputReleaseAssets: () => string[];
//# sourceMappingURL=inputProcessors.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/inputProcessors.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/utilities/installDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { AdditionalPluginsSpec } from './inputProcessors.js';
export declare const installDependencies: (additionalPlugins?: AdditionalPluginsSpec) => Promise<void>;
//# sourceMappingURL=installDependencies.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/installDependencies.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/utilities/outputParsers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Result } from 'semantic-release';
export declare const reportResults: (result: Result) => void;
//# sourceMappingURL=outputParsers.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/outputParsers.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions dist/utilities/parseConfiguration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Options } from 'semantic-release';
/**
* Returns a semantic release configuration object when given a filepath.
* @param filePath File path of the .yaml or .js configuration file.
* @param defaultOptions Default action options that are passed to the function
* exported by the .js configuration module.
*/
export declare const parseConfiguration: (filePath: string, defaultOptions: Options) => Promise<object>;
//# sourceMappingURL=parseConfiguration.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/parseConfiguration.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/utilities/transform.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Commit } from 'conventional-commits-parser';
export declare const transform: (commit: Commit) => unknown;
//# sourceMappingURL=transform.d.ts.map
1 change: 1 addition & 0 deletions dist/utilities/transform.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setFailed } from '@actions/core';
import { Config, Options, Result } from 'semantic-release';
import type { Config, Options, Result } from 'semantic-release';

import { getSetFailedErrorString } from './utilities/error.js';
import { generatePlugins } from './utilities/generatePlugins.js';
Expand Down
132 changes: 65 additions & 67 deletions src/utilities/generatePlugins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PluginSpec } from 'semantic-release';
import type { PluginSpec } from 'semantic-release';

import { ReleaseRule } from './inputProcessors.js';
import type { ReleaseRule } from './inputProcessors.js';
import { transform } from './transform.js';

/* eslint-disable-next-line max-lines-per-function */
Expand All @@ -16,72 +16,70 @@ export const generatePlugins = ({
isNodeModule: boolean;
releaseAssets: string[];
releaseRules: ReleaseRule[];
}): PluginSpec[] =>
/* eslint-disable unicorn/prevent-abbreviations */
}): PluginSpec[] /* eslint-disable unicorn/prevent-abbreviations */ => [
[
[
'@semantic-release/commit-analyzer',
{
parserOpts: {
mergeCorrespondence: ['id', 'source'],
mergePattern: /^Merge pull request #\d+ from .*$/u,
},
preset: 'angular',
releaseRules,
'@semantic-release/commit-analyzer',
{
parserOpts: {
mergeCorrespondence: ['id', 'source'],
mergePattern: /^Merge pull request #\d+ from .*$/u,
},
],
[
'@semantic-release/release-notes-generator',
{
preset: 'angular',
writerOpts: {
transform,
},
},
],
...(disableChangeLog === false
? [
'@semantic-release/changelog',
[
'@semantic-release/exec',
{
prepareCmd: 'npx prettier --parser markdown --write CHANGELOG.md',
},
] as PluginSpec,
]
: []),
...(isNodeModule === true
? [
[
'@semantic-release/npm',
{
npmPublish: false,
},
] as PluginSpec,
]
: []),
[
'@semantic-release/git',
{
assets: [
...(disableChangeLog === false ? ['./CHANGELOG.md'] : []),
...commitAssets,
...(isNodeModule
? ['./package.json', './package-lock.json', './yarn-lock.yaml']
: []),
],
/* eslint-disable-next-line no-template-curly-in-string */
message: 'chore(release): v${nextRelease.version}',
},
],
[
'@semantic-release/github',
{
assets: releaseAssets,
failComment: false,
releasedLabels: false,
successComment: false,
preset: 'angular',
releaseRules,
},
],
[
'@semantic-release/release-notes-generator',
{
preset: 'angular',
writerOpts: {
transform,
},
],
];
},
],
...(disableChangeLog === false
? [
'@semantic-release/changelog',
[
'@semantic-release/exec',
{
prepareCmd: 'npx prettier --parser markdown --write CHANGELOG.md',
},
] as PluginSpec,
]
: []),
...(isNodeModule === true
? [
[
'@semantic-release/npm',
{
npmPublish: false,
},
] as PluginSpec,
]
: []),
[
'@semantic-release/git',
{
assets: [
...(disableChangeLog === false ? ['./CHANGELOG.md'] : []),
...commitAssets,
...(isNodeModule
? ['./package.json', './package-lock.json', './yarn-lock.yaml']
: []),
],
/* eslint-disable-next-line no-template-curly-in-string */
message: 'chore(release): v${nextRelease.version}',
},
],
[
'@semantic-release/github',
{
assets: releaseAssets,
failComment: false,
releasedLabels: false,
successComment: false,
},
],
];
/* eslint-enable unicorn/prevent-abbreviations */
32 changes: 17 additions & 15 deletions src/utilities/git.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable no-duplicate-imports */
/* eslint-disable no-await-in-loop */
import { $, Options } from "execa";
import fileUrl from "file-url";
import { temporaryDirectory } from "tempy";
import type { Options } from 'execa';
import { $ } from 'execa';
import fileUrl from 'file-url';
import { temporaryDirectory } from 'tempy';

/**
* Initialize local `remote` git repository in a temporary temporaryDirectory.
Expand All @@ -28,9 +30,9 @@ export const gitShallowClone = async (
const cloneWorkingDirectory = temporaryDirectory();

const gitArguments = [
"--no-hardlinks",
"--no-tags",
"--depth",
'--no-hardlinks',
'--no-tags',
'--depth',
depth.toString(),
repositoryUrl,
cloneWorkingDirectory,
Expand All @@ -48,7 +50,7 @@ export const gitCommits = async (
execaOptions: Options,
): Promise<void> => {
for (const message of messages) {
const gitArguments = ["-m", message, "--allow-empty", "--no-gpg-sign"];
const gitArguments = ['-m', message, '--allow-empty', '--no-gpg-sign'];

await $(execaOptions)`git commit ${gitArguments}`;
}
Expand All @@ -62,7 +64,7 @@ export const gitTagVersion = async (
tagName: string,
execaOptions: Options,
): Promise<void> => {
const gitArguments = ["tag", tagName];
const gitArguments = ['tag', tagName];
await $(execaOptions)`git ${gitArguments}`;
};

Expand All @@ -79,20 +81,20 @@ export const gitRepo = async (): Promise<{
const cloneWorkingDirectory = await gitShallowClone(remoteRepositoryUrl);
const execaOptions = { cwd: cloneWorkingDirectory };

const gitArgumentsEmail = ["config", "user.email", "[email protected]"];
const gitArgumentsEmail = ['config', 'user.email', '[email protected]'];
await $(execaOptions)`git ${gitArgumentsEmail}`;

const gitArgumentsName = ["config", "user.name", "[email protected]"];
const gitArgumentsName = ['config', 'user.name', '[email protected]'];
await $(execaOptions)`git ${gitArgumentsName}`;

const gitArgumentsGpgSign = ["config", "commit.gpgsign", "false"];
const gitArgumentsGpgSign = ['config', 'commit.gpgsign', 'false'];
await $(execaOptions)`git ${gitArgumentsGpgSign}`;
await $(execaOptions)`npm init -y`;
await $(execaOptions)`git add --all`;
await gitCommits(["feat: initial commit"], { cwd: cloneWorkingDirectory });
await gitTagVersion("v1.0.0", { cwd: cloneWorkingDirectory });
await gitCommits(['feat: initial commit'], { cwd: cloneWorkingDirectory });
await gitTagVersion('v1.0.0', { cwd: cloneWorkingDirectory });

const gitArgumentsPush = ["push", remoteRepositoryUrl];
const gitArgumentsPush = ['push', remoteRepositoryUrl];
await $(execaOptions)`git ${gitArgumentsPush}`;

return { cwd: cloneWorkingDirectory, repositoryUrl: remoteRepositoryUrl };
Expand All @@ -107,6 +109,6 @@ export const gitPush = async (
branch: string,
execaOptions: Options,
): Promise<void> => {
const gitPushArguments = ["--tags", repositoryUrl, `HEAD:${branch}`];
const gitPushArguments = ['--tags', repositoryUrl, `HEAD:${branch}`];
await $(execaOptions)`git push ${gitPushArguments}`;
};
2 changes: 1 addition & 1 deletion src/utilities/inputProcessors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getInput } from '@actions/core';
import joi from 'joi';
import { BranchSpec } from 'semantic-release';
import type { BranchSpec } from 'semantic-release';

const MATCH_CONFIG_FILE_EXTENSION_REGEXP = /\.(?:ya?ml|js)$/u;

Expand Down
Loading

0 comments on commit b7b43f6

Please sign in to comment.