@hubspot/npm-scripts 0.2.1 → 0.3.0-beta.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/package.json +1 -1
- package/src/release.js +18 -8
- package/src/repo-sync.d.ts +1 -1
- package/src/repo-sync.js +6 -3
- package/src/types.d.ts +2 -0
package/package.json
CHANGED
package/src/release.js
CHANGED
|
@@ -12,7 +12,7 @@ import { getDistTags, publish, updateNextTag, updatePreviousTag, } from './utils
|
|
|
12
12
|
import { confirm, input } from './utils/prompting.js';
|
|
13
13
|
const exec = promisify(_exec);
|
|
14
14
|
function buildHandler({ build, postLatestRelease, packageName, localVersion, registry, repositoryUrl, mainBranch, previousBranch, ignoreScripts, }) {
|
|
15
|
-
return async function handler({ versionIncrement, tag, dryRun, skipBranchValidation, }) {
|
|
15
|
+
return async function handler({ versionIncrement, tag, dryRun, skipBranchValidation, skipVersionCheck, }) {
|
|
16
16
|
const branch = await getCurrentGitBranch();
|
|
17
17
|
const isExperimental = tag === TAG.EXPERIMENTAL;
|
|
18
18
|
const isPrevious = tag === TAG.PREVIOUS;
|
|
@@ -42,13 +42,15 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
|
|
|
42
42
|
process.exit(EXIT_CODES.ERROR);
|
|
43
43
|
}
|
|
44
44
|
const { latest: currentLatestTag, next: currentNextTag, experimental: currentExperimentalTag, previous: currentPreviousTag, } = await getDistTags(packageName);
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (!skipVersionCheck) {
|
|
46
|
+
if (!isExperimental && !isPrevious && currentNextTag !== localVersion) {
|
|
47
|
+
logger.error(`Local package.json version ${localVersion} is out of sync with published version ${currentNextTag}`);
|
|
48
|
+
process.exit(EXIT_CODES.ERROR);
|
|
49
|
+
}
|
|
50
|
+
if (isPrevious && currentPreviousTag !== localVersion) {
|
|
51
|
+
logger.error(`Local package.json version ${localVersion} is out of sync with published version ${currentPreviousTag}`);
|
|
52
|
+
process.exit(EXIT_CODES.ERROR);
|
|
53
|
+
}
|
|
52
54
|
}
|
|
53
55
|
const currentVersion = isExperimental
|
|
54
56
|
? currentExperimentalTag
|
|
@@ -105,6 +107,9 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
|
|
|
105
107
|
await build();
|
|
106
108
|
}
|
|
107
109
|
else {
|
|
110
|
+
logger.log('Installing dependencies...');
|
|
111
|
+
await exec('yarn');
|
|
112
|
+
logger.log('Building...');
|
|
108
113
|
await exec(`yarn build`);
|
|
109
114
|
}
|
|
110
115
|
let otp = '';
|
|
@@ -213,6 +218,11 @@ async function builder(yargs) {
|
|
|
213
218
|
default: false,
|
|
214
219
|
type: 'boolean',
|
|
215
220
|
},
|
|
221
|
+
skipVersionCheck: {
|
|
222
|
+
describe: 'Bypass checking that the local version matches the published version',
|
|
223
|
+
default: false,
|
|
224
|
+
type: 'boolean',
|
|
225
|
+
},
|
|
216
226
|
});
|
|
217
227
|
}
|
|
218
228
|
export function buildReleaseScript({ packageJsonLocation, buildHandlerOptions, }) {
|
package/src/repo-sync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildRepoSyncScriptOptions, RepoSyncArguments } from './types.js';
|
|
2
|
-
export declare function handleRepoSync({ targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, version, dryRun, sshKeyPath, }: BuildRepoSyncScriptOptions & RepoSyncArguments): Promise<void>;
|
|
2
|
+
export declare function handleRepoSync({ sourceDirectory, targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, version, dryRun, sshKeyPath, }: BuildRepoSyncScriptOptions & RepoSyncArguments): Promise<void>;
|
|
3
3
|
export declare function buildRepoSyncScript({ buildHandlerOptions, }: {
|
|
4
4
|
buildHandlerOptions: BuildRepoSyncScriptOptions;
|
|
5
5
|
}): void;
|
package/src/repo-sync.js
CHANGED
|
@@ -8,14 +8,16 @@ import { DEFAULT_INTERNAL_MAIN_BRANCH, DEFAULT_EXTERNAL_MAIN_BRANCH, SYNC_BRANCH
|
|
|
8
8
|
import { checkoutBranch, cloneRepo, commitChanges, createBranch, getCurrentGitBranch, getGitEnvWithSshKey, pushBranch, } from './utils/git.js';
|
|
9
9
|
import { copyFiles } from './utils/filesystem.js';
|
|
10
10
|
import { confirm } from './utils/prompting.js';
|
|
11
|
-
export async function handleRepoSync({ targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, version, dryRun, sshKeyPath, }) {
|
|
11
|
+
export async function handleRepoSync({ sourceDirectory, targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, version, dryRun, sshKeyPath, }) {
|
|
12
12
|
if (!internalMainBranch) {
|
|
13
13
|
internalMainBranch = DEFAULT_INTERNAL_MAIN_BRANCH;
|
|
14
14
|
}
|
|
15
15
|
if (!externalMainBranch) {
|
|
16
16
|
externalMainBranch = DEFAULT_EXTERNAL_MAIN_BRANCH;
|
|
17
17
|
}
|
|
18
|
-
const originalRepoPath =
|
|
18
|
+
const originalRepoPath = sourceDirectory
|
|
19
|
+
? path.resolve(sourceDirectory)
|
|
20
|
+
: process.cwd();
|
|
19
21
|
let tempDir = '';
|
|
20
22
|
try {
|
|
21
23
|
logger.log(`Starting sync to target repository: ${targetRepositoryUrl}...`);
|
|
@@ -86,9 +88,10 @@ export async function handleRepoSync({ targetRepositoryUrl, excludePatterns, bui
|
|
|
86
88
|
process.chdir(originalRepoPath);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
|
-
function buildHandler({ targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, }) {
|
|
91
|
+
function buildHandler({ sourceDirectory, targetRepositoryUrl, excludePatterns, buildCommitMessage, internalMainBranch, externalMainBranch, }) {
|
|
90
92
|
return async function handler({ version, dryRun, sshKeyPath, }) {
|
|
91
93
|
await handleRepoSync({
|
|
94
|
+
sourceDirectory,
|
|
92
95
|
targetRepositoryUrl,
|
|
93
96
|
excludePatterns,
|
|
94
97
|
buildCommitMessage,
|
package/src/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type ReleaseArguments = {
|
|
|
4
4
|
tag: (typeof TAG_OPTIONS)[number];
|
|
5
5
|
dryRun: boolean;
|
|
6
6
|
skipBranchValidation: boolean;
|
|
7
|
+
skipVersionCheck: boolean;
|
|
7
8
|
};
|
|
8
9
|
export type RepoSyncArguments = {
|
|
9
10
|
version: string;
|
|
@@ -34,6 +35,7 @@ export interface BuildReleaseScriptOptions extends BuildReleaseScriptBase {
|
|
|
34
35
|
registry: string;
|
|
35
36
|
}
|
|
36
37
|
export interface BuildRepoSyncScriptOptions {
|
|
38
|
+
sourceDirectory?: string;
|
|
37
39
|
targetRepositoryUrl: string;
|
|
38
40
|
buildCommitMessage: (version: string) => string;
|
|
39
41
|
excludePatterns?: string[];
|