@atlaskit/dependency-version-analytics 1.4.7 → 1.4.8
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 +6 -0
- package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +45 -36
- package/dist/cjs/commands/populate-historic-data/util/allowed-scopes.js +2 -15
- package/dist/cjs/commands/populate-historic-data/util/generate-csv.js +0 -3
- package/dist/cjs/util/analytics.js +1 -3
- package/dist/cjs/util/git.js +1 -3
- package/dist/cjs/util/yarn.js +4 -4
- package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +46 -37
- package/dist/es2019/commands/populate-historic-data/util/allowed-scopes.js +0 -12
- package/dist/es2019/commands/populate-historic-data/util/generate-csv.js +0 -3
- package/dist/es2019/util/analytics.js +1 -2
- package/dist/es2019/util/git.js +1 -3
- package/dist/es2019/util/yarn.js +3 -3
- package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +53 -51
- package/dist/esm/commands/populate-historic-data/util/allowed-scopes.js +0 -14
- package/dist/esm/commands/populate-historic-data/util/generate-csv.js +0 -3
- package/dist/esm/util/analytics.js +1 -2
- package/dist/esm/util/git.js +1 -3
- package/dist/esm/util/yarn.js +7 -7
- package/dist/types/commands/populate-historic-data/__fixtures__/git.d.ts +5 -1
- package/dist/types/commands/populate-historic-data/lib/dependency-store.d.ts +3 -4
- package/dist/types/commands/populate-historic-data/util/allowed-scopes.d.ts +0 -6
- package/dist/types/util/yarn.d.ts +1 -1
- package/dist/types-ts4.5/commands/populate-historic-data/__fixtures__/git.d.ts +5 -1
- package/dist/types-ts4.5/commands/populate-historic-data/lib/dependency-store.d.ts +3 -4
- package/dist/types-ts4.5/commands/populate-historic-data/util/allowed-scopes.d.ts +0 -6
- package/dist/types-ts4.5/util/yarn.d.ts +1 -1
- package/jest.config.js +5 -0
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/dependency-version-analytics
|
|
2
2
|
|
|
3
|
+
## 1.4.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`27db2e84c40`](https://bitbucket.org/atlassian/atlassian-frontend/commits/27db2e84c40) - Removing '--current' postfix from packageName before checking it for support
|
|
8
|
+
|
|
3
9
|
## 1.4.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -24,8 +24,8 @@ class DependencyStore {
|
|
|
24
24
|
dependencies = {};
|
|
25
25
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
26
26
|
workspaces = {};
|
|
27
|
-
/** Set of workspace
|
|
28
|
-
|
|
27
|
+
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
28
|
+
workspacePackageJsonPaths = new Set();
|
|
29
29
|
initialised = false;
|
|
30
30
|
constructor(cwd = process.cwd(), supportedScopes, supportedPackages) {
|
|
31
31
|
this.cwd = cwd;
|
|
@@ -49,18 +49,18 @@ class DependencyStore {
|
|
|
49
49
|
this.assertInitialised();
|
|
50
50
|
const hash = logItem.hash;
|
|
51
51
|
(0, _assert.assert)(!!logItem.diff, `Diff must exist in log ${logItem} ${hash}`);
|
|
52
|
-
const changedPackageJsons = logItem.diff.files.filter(f => f.file
|
|
52
|
+
const changedPackageJsons = logItem.diff.files.filter(f => f.file.endsWith('package.json')).map(f => f.file);
|
|
53
53
|
const didRootPackageJsonChange = !!changedPackageJsons.find(file => file === 'package.json');
|
|
54
54
|
if (didRootPackageJsonChange) {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
debug(`Workspace globs changed: ${[...
|
|
55
|
+
const workspacePackageJsonPaths = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.cwd);
|
|
56
|
+
const workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || [...this.workspacePackageJsonPaths].some(glob => !workspacePackageJsonPaths.has(glob)));
|
|
57
|
+
if (workspacePackageJsonPathsChanged) {
|
|
58
|
+
debug(`Workspace globs changed: ${[...workspacePackageJsonPaths]}. Resetting store.`);
|
|
59
59
|
await this.resetStore(hash);
|
|
60
60
|
return this.getFlattenedDeps();
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
const changedWorkspaces = (0, _micromatch.default)(changedPackageJsons, [...this.
|
|
63
|
+
const changedWorkspaces = (0, _micromatch.default)(changedPackageJsons, [...this.workspacePackageJsonPaths]);
|
|
64
64
|
debug(`Updating changed workspaces@${hash}: ${changedWorkspaces}`);
|
|
65
65
|
|
|
66
66
|
// Iterate over all changed package.jsons rather than only valid workspaces so that we can
|
|
@@ -95,7 +95,7 @@ class DependencyStore {
|
|
|
95
95
|
*/
|
|
96
96
|
getFlattenedDeps() {
|
|
97
97
|
const deps = Object.entries(this.dependencies).filter(([, versions]) => versions.length > 0).map(([depName, versions]) => [depName, DependencyStore.getMinimumVersion(versions, depName)]);
|
|
98
|
-
return fromEntries(deps);
|
|
98
|
+
return Object.fromEntries(deps);
|
|
99
99
|
}
|
|
100
100
|
assertInitialised() {
|
|
101
101
|
if (!this.initialised) {
|
|
@@ -104,20 +104,20 @@ class DependencyStore {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/** Scans all workspaces in repo and rebuilds dependency store */
|
|
107
|
-
async resetStore(
|
|
107
|
+
async resetStore(hash) {
|
|
108
108
|
this.dependencies = {};
|
|
109
109
|
this.workspaces = {};
|
|
110
|
-
const workspaceGlobs = await (0, _yarn.
|
|
110
|
+
const workspaceGlobs = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.cwd);
|
|
111
111
|
if (workspaceGlobs !== null) {
|
|
112
|
-
this.
|
|
112
|
+
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
113
113
|
}
|
|
114
|
-
const workspacePaths = await (0, _yarn.getWorkspacePaths)(
|
|
114
|
+
const workspacePaths = await (0, _yarn.getWorkspacePaths)(hash, this.workspacePackageJsonPaths, this.cwd);
|
|
115
115
|
debug(`Workspace paths: ${workspacePaths}`);
|
|
116
116
|
for (const wsPath of workspacePaths) {
|
|
117
117
|
if (this.workspaces[wsPath]) {
|
|
118
118
|
throw new Error(`Duplicate workspace path found: ${wsPath}`);
|
|
119
119
|
}
|
|
120
|
-
const workspaceDeps = await this.getWorkspaceDependencies(
|
|
120
|
+
const workspaceDeps = await this.getWorkspaceDependencies(hash, wsPath);
|
|
121
121
|
if (workspaceDeps == null) {
|
|
122
122
|
continue;
|
|
123
123
|
}
|
|
@@ -209,13 +209,36 @@ class DependencyStore {
|
|
|
209
209
|
this.dependencies[depName] = this.dependencies[depName].filter(entry => entry !== depEntry);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
getSupportedDependencies(depMap,
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
getSupportedDependencies(depMap, dependencyType) {
|
|
213
|
+
return Object.entries(depMap).reduce((supportedDependencies, [rawPackageName, packageVersion]) => {
|
|
214
|
+
// Ignore suffixed `--next` deps in jira used for independent upgrades
|
|
215
|
+
if (rawPackageName.endsWith('--next')) {
|
|
216
|
+
return supportedDependencies;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Treat `--current` as the standard dependency
|
|
220
|
+
const packageName = rawPackageName.replace(/--current$/, '');
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Checks if the package is from supported scope
|
|
224
|
+
* and if so, checks if the package is also from supported package list.
|
|
225
|
+
*/
|
|
226
|
+
const isPackageSupported = (0, _allowedScopes.isPackageFromSupportedScopes)(packageName, this.supportedScopes) && (
|
|
227
|
+
// If supportedPackages wasn't specified, then we allow ANY packages
|
|
228
|
+
!this.supportedPackages.length ||
|
|
229
|
+
/**
|
|
230
|
+
* All packageName's formatting, such as removing "--current" postfix, MUST be performed BEFORE the next line
|
|
231
|
+
* Packages in supportedPackages don't have postfixes, so checking for package with postfix will always return false
|
|
232
|
+
*/
|
|
233
|
+
this.supportedPackages.includes(packageName));
|
|
234
|
+
if (isPackageSupported) {
|
|
235
|
+
supportedDependencies[packageName] = {
|
|
236
|
+
version: DependencyStore.transformDepVersion(packageVersion),
|
|
237
|
+
type: dependencyType
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return supportedDependencies;
|
|
241
|
+
}, {});
|
|
219
242
|
}
|
|
220
243
|
static getMinimumVersion(versions, depName) {
|
|
221
244
|
const depOrder = ['dependency', 'peerDependency', 'devDependency', 'optionalDependency'];
|
|
@@ -244,10 +267,6 @@ class DependencyStore {
|
|
|
244
267
|
}
|
|
245
268
|
return sorted[0];
|
|
246
269
|
}
|
|
247
|
-
static transformDepName(name) {
|
|
248
|
-
// Treat `--current` as the standard dependency
|
|
249
|
-
return name.replace(/--current$/, '');
|
|
250
|
-
}
|
|
251
270
|
|
|
252
271
|
/* Coerce non-standard versions to a semver version.
|
|
253
272
|
* This essentially ignores everything up until the first number and then tries to parse a version
|
|
@@ -259,14 +278,4 @@ class DependencyStore {
|
|
|
259
278
|
return parts[parts.length - 1];
|
|
260
279
|
}
|
|
261
280
|
}
|
|
262
|
-
|
|
263
|
-
// Object.fromEntries polyfill, remove when upgraded to node 10
|
|
264
|
-
exports.DependencyStore = DependencyStore;
|
|
265
|
-
function fromEntries(iterable) {
|
|
266
|
-
return [...iterable].reduce((obj, {
|
|
267
|
-
0: key,
|
|
268
|
-
1: val
|
|
269
|
-
}) => Object.assign(obj, {
|
|
270
|
-
[key]: val
|
|
271
|
-
}), {});
|
|
272
|
-
}
|
|
281
|
+
exports.DependencyStore = DependencyStore;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isPackageFromSupportedScopes = exports.getSupportedScopes = void 0;
|
|
7
7
|
const defaultScopes = ['@atlaskit', '@atlassian', '@atlassiansox'];
|
|
8
8
|
const getSupportedScopes = (enableNonAtlaskitPackages = false) => {
|
|
9
9
|
return enableNonAtlaskitPackages ? defaultScopes : ['@atlaskit'];
|
|
@@ -12,17 +12,4 @@ exports.getSupportedScopes = getSupportedScopes;
|
|
|
12
12
|
const isPackageFromSupportedScopes = (packageName, supportedScopes = defaultScopes) => {
|
|
13
13
|
return supportedScopes.some(scope => packageName.startsWith(scope));
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* Checks if the package is from supported scope
|
|
19
|
-
* and if so, the package is also from supported package list.
|
|
20
|
-
*/
|
|
21
|
-
exports.isPackageFromSupportedScopes = isPackageFromSupportedScopes;
|
|
22
|
-
const isPackageSupported = (packageName, supportedPackages = [], supportedScopes = defaultScopes) => {
|
|
23
|
-
if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
|
|
24
|
-
return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
};
|
|
28
|
-
exports.isPackageSupported = isPackageSupported;
|
|
15
|
+
exports.isPackageFromSupportedScopes = isPackageFromSupportedScopes;
|
|
@@ -17,15 +17,12 @@ const generateCSV = packageChanges => {
|
|
|
17
17
|
if (depColumnIndex === -1) {
|
|
18
18
|
depColumnIndex = csvData.push([name]) - 1;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
// console.log(csvData)
|
|
22
20
|
csvData[depColumnIndex][currentRow] = version;
|
|
23
21
|
});
|
|
24
22
|
});
|
|
25
23
|
for (let i = 0; i < csvData.length; i++) {
|
|
26
24
|
for (let j = 0; j < csvData.length; j++) {
|
|
27
25
|
if (typeof csvData[i][j] !== 'string') {
|
|
28
|
-
// console.log('found empty cell');
|
|
29
26
|
csvData[i][j] = '';
|
|
30
27
|
}
|
|
31
28
|
}
|
|
@@ -10,8 +10,6 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
10
10
|
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
11
11
|
var _semver = _interopRequireDefault(require("semver"));
|
|
12
12
|
var _analyticsNodeClient = require("@atlassiansox/analytics-node-client");
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
|
|
15
13
|
/* eslint-disable-next-line import/no-unresolved */
|
|
16
14
|
|
|
17
15
|
function getUpgradeType(version, previousVersion) {
|
|
@@ -69,7 +67,7 @@ function createUpgradeEvent(name, version, previousVersion, date, optionalEventA
|
|
|
69
67
|
}
|
|
70
68
|
});
|
|
71
69
|
return {
|
|
72
|
-
cliVersion: "1.4.
|
|
70
|
+
cliVersion: "1.4.8",
|
|
73
71
|
dependencyName: name,
|
|
74
72
|
versionString: eventVersion,
|
|
75
73
|
major: parsedVersion ? `${parsedVersion.major}` : null,
|
package/dist/cjs/util/git.js
CHANGED
|
@@ -13,8 +13,6 @@ exports.showFile = showFile;
|
|
|
13
13
|
exports.tagCommit = tagCommit;
|
|
14
14
|
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
15
15
|
var _assert = require("./assert");
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
|
|
18
16
|
async function getChangesSince(since) {
|
|
19
17
|
const revisionRange = since ? [`${since}..`] : [];
|
|
20
18
|
const listLogSummary = await (0, _simpleGit.default)().log([
|
|
@@ -28,7 +26,7 @@ async function getChangesSince(since) {
|
|
|
28
26
|
'--stat=4096',
|
|
29
27
|
// Make +- graph width as small as possible to maximise filename length
|
|
30
28
|
'--stat-graph-width=1', ...revisionRange,
|
|
31
|
-
// Any commit that modifies a package.json
|
|
29
|
+
// Any commit that modifies a package.json in any directory
|
|
32
30
|
':(glob)**/package.json']);
|
|
33
31
|
return {
|
|
34
32
|
...listLogSummary,
|
package/dist/cjs/util/yarn.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.getWorkspacePackageJsonPaths = getWorkspacePackageJsonPaths;
|
|
8
8
|
exports.getWorkspacePaths = getWorkspacePaths;
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
@@ -14,10 +14,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
const rootPackageJsonPath = 'package.json';
|
|
16
16
|
const debug = (0, _debug.default)('atlaskit:yarn');
|
|
17
|
-
async function
|
|
17
|
+
async function getWorkspacePackageJsonPaths(hash, cwd) {
|
|
18
18
|
let file;
|
|
19
19
|
try {
|
|
20
|
-
file = await git.showFile(
|
|
20
|
+
file = await git.showFile(hash, rootPackageJsonPath, {
|
|
21
21
|
cwd
|
|
22
22
|
});
|
|
23
23
|
} catch (e) {
|
|
@@ -28,7 +28,7 @@ async function getWorkspaceGlobs(ref, cwd) {
|
|
|
28
28
|
try {
|
|
29
29
|
rootPackageJsonFile = JSON.parse(file);
|
|
30
30
|
} catch (e) {
|
|
31
|
-
console.error(`Error parsing ${file}@${
|
|
31
|
+
console.error(`Error parsing ${file}@${hash}: ${e}`);
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
const workspaces = rootPackageJsonFile.workspaces;
|
|
@@ -3,12 +3,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
|
|
4
4
|
import debugModule from 'debug';
|
|
5
5
|
import semver from 'semver';
|
|
6
|
-
import { getWorkspacePaths,
|
|
6
|
+
import { getWorkspacePaths, getWorkspacePackageJsonPaths } from '../../../util/yarn';
|
|
7
7
|
import { showFile } from '../../../util/git';
|
|
8
8
|
import { DEP_TYPES } from '../../../constants';
|
|
9
9
|
import { assert } from '../../../util/assert';
|
|
10
10
|
import micromatch from 'micromatch';
|
|
11
|
-
import {
|
|
11
|
+
import { isPackageFromSupportedScopes } from '../util/allowed-scopes';
|
|
12
12
|
const debug = debugModule('atlaskit:dependency');
|
|
13
13
|
/**
|
|
14
14
|
* Stores the state of atlaskit dependencies in a repository
|
|
@@ -19,8 +19,8 @@ export class DependencyStore {
|
|
|
19
19
|
_defineProperty(this, "dependencies", {});
|
|
20
20
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
21
21
|
_defineProperty(this, "workspaces", {});
|
|
22
|
-
/** Set of workspace
|
|
23
|
-
_defineProperty(this, "
|
|
22
|
+
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
23
|
+
_defineProperty(this, "workspacePackageJsonPaths", new Set());
|
|
24
24
|
_defineProperty(this, "initialised", false);
|
|
25
25
|
this.cwd = cwd;
|
|
26
26
|
this.supportedScopes = supportedScopes;
|
|
@@ -43,18 +43,18 @@ export class DependencyStore {
|
|
|
43
43
|
this.assertInitialised();
|
|
44
44
|
const hash = logItem.hash;
|
|
45
45
|
assert(!!logItem.diff, `Diff must exist in log ${logItem} ${hash}`);
|
|
46
|
-
const changedPackageJsons = logItem.diff.files.filter(f => f.file
|
|
46
|
+
const changedPackageJsons = logItem.diff.files.filter(f => f.file.endsWith('package.json')).map(f => f.file);
|
|
47
47
|
const didRootPackageJsonChange = !!changedPackageJsons.find(file => file === 'package.json');
|
|
48
48
|
if (didRootPackageJsonChange) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
debug(`Workspace globs changed: ${[...
|
|
49
|
+
const workspacePackageJsonPaths = await getWorkspacePackageJsonPaths(hash, this.cwd);
|
|
50
|
+
const workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || [...this.workspacePackageJsonPaths].some(glob => !workspacePackageJsonPaths.has(glob)));
|
|
51
|
+
if (workspacePackageJsonPathsChanged) {
|
|
52
|
+
debug(`Workspace globs changed: ${[...workspacePackageJsonPaths]}. Resetting store.`);
|
|
53
53
|
await this.resetStore(hash);
|
|
54
54
|
return this.getFlattenedDeps();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const changedWorkspaces = micromatch(changedPackageJsons, [...this.
|
|
57
|
+
const changedWorkspaces = micromatch(changedPackageJsons, [...this.workspacePackageJsonPaths]);
|
|
58
58
|
debug(`Updating changed workspaces@${hash}: ${changedWorkspaces}`);
|
|
59
59
|
|
|
60
60
|
// Iterate over all changed package.jsons rather than only valid workspaces so that we can
|
|
@@ -89,7 +89,7 @@ export class DependencyStore {
|
|
|
89
89
|
*/
|
|
90
90
|
getFlattenedDeps() {
|
|
91
91
|
const deps = Object.entries(this.dependencies).filter(([, versions]) => versions.length > 0).map(([depName, versions]) => [depName, DependencyStore.getMinimumVersion(versions, depName)]);
|
|
92
|
-
return fromEntries(deps);
|
|
92
|
+
return Object.fromEntries(deps);
|
|
93
93
|
}
|
|
94
94
|
assertInitialised() {
|
|
95
95
|
if (!this.initialised) {
|
|
@@ -98,20 +98,20 @@ export class DependencyStore {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/** Scans all workspaces in repo and rebuilds dependency store */
|
|
101
|
-
async resetStore(
|
|
101
|
+
async resetStore(hash) {
|
|
102
102
|
this.dependencies = {};
|
|
103
103
|
this.workspaces = {};
|
|
104
|
-
const workspaceGlobs = await
|
|
104
|
+
const workspaceGlobs = await getWorkspacePackageJsonPaths(hash, this.cwd);
|
|
105
105
|
if (workspaceGlobs !== null) {
|
|
106
|
-
this.
|
|
106
|
+
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
107
107
|
}
|
|
108
|
-
const workspacePaths = await getWorkspacePaths(
|
|
108
|
+
const workspacePaths = await getWorkspacePaths(hash, this.workspacePackageJsonPaths, this.cwd);
|
|
109
109
|
debug(`Workspace paths: ${workspacePaths}`);
|
|
110
110
|
for (const wsPath of workspacePaths) {
|
|
111
111
|
if (this.workspaces[wsPath]) {
|
|
112
112
|
throw new Error(`Duplicate workspace path found: ${wsPath}`);
|
|
113
113
|
}
|
|
114
|
-
const workspaceDeps = await this.getWorkspaceDependencies(
|
|
114
|
+
const workspaceDeps = await this.getWorkspaceDependencies(hash, wsPath);
|
|
115
115
|
if (workspaceDeps == null) {
|
|
116
116
|
continue;
|
|
117
117
|
}
|
|
@@ -203,13 +203,36 @@ export class DependencyStore {
|
|
|
203
203
|
this.dependencies[depName] = this.dependencies[depName].filter(entry => entry !== depEntry);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
getSupportedDependencies(depMap,
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
getSupportedDependencies(depMap, dependencyType) {
|
|
207
|
+
return Object.entries(depMap).reduce((supportedDependencies, [rawPackageName, packageVersion]) => {
|
|
208
|
+
// Ignore suffixed `--next` deps in jira used for independent upgrades
|
|
209
|
+
if (rawPackageName.endsWith('--next')) {
|
|
210
|
+
return supportedDependencies;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Treat `--current` as the standard dependency
|
|
214
|
+
const packageName = rawPackageName.replace(/--current$/, '');
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Checks if the package is from supported scope
|
|
218
|
+
* and if so, checks if the package is also from supported package list.
|
|
219
|
+
*/
|
|
220
|
+
const isPackageSupported = isPackageFromSupportedScopes(packageName, this.supportedScopes) && (
|
|
221
|
+
// If supportedPackages wasn't specified, then we allow ANY packages
|
|
222
|
+
!this.supportedPackages.length ||
|
|
223
|
+
/**
|
|
224
|
+
* All packageName's formatting, such as removing "--current" postfix, MUST be performed BEFORE the next line
|
|
225
|
+
* Packages in supportedPackages don't have postfixes, so checking for package with postfix will always return false
|
|
226
|
+
*/
|
|
227
|
+
this.supportedPackages.includes(packageName));
|
|
228
|
+
if (isPackageSupported) {
|
|
229
|
+
supportedDependencies[packageName] = {
|
|
230
|
+
version: DependencyStore.transformDepVersion(packageVersion),
|
|
231
|
+
type: dependencyType
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
return supportedDependencies;
|
|
235
|
+
}, {});
|
|
213
236
|
}
|
|
214
237
|
static getMinimumVersion(versions, depName) {
|
|
215
238
|
const depOrder = ['dependency', 'peerDependency', 'devDependency', 'optionalDependency'];
|
|
@@ -238,10 +261,6 @@ export class DependencyStore {
|
|
|
238
261
|
}
|
|
239
262
|
return sorted[0];
|
|
240
263
|
}
|
|
241
|
-
static transformDepName(name) {
|
|
242
|
-
// Treat `--current` as the standard dependency
|
|
243
|
-
return name.replace(/--current$/, '');
|
|
244
|
-
}
|
|
245
264
|
|
|
246
265
|
/* Coerce non-standard versions to a semver version.
|
|
247
266
|
* This essentially ignores everything up until the first number and then tries to parse a version
|
|
@@ -252,14 +271,4 @@ export class DependencyStore {
|
|
|
252
271
|
const parts = version.split('@');
|
|
253
272
|
return parts[parts.length - 1];
|
|
254
273
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// Object.fromEntries polyfill, remove when upgraded to node 10
|
|
258
|
-
function fromEntries(iterable) {
|
|
259
|
-
return [...iterable].reduce((obj, {
|
|
260
|
-
0: key,
|
|
261
|
-
1: val
|
|
262
|
-
}) => Object.assign(obj, {
|
|
263
|
-
[key]: val
|
|
264
|
-
}), {});
|
|
265
274
|
}
|
|
@@ -4,16 +4,4 @@ export const getSupportedScopes = (enableNonAtlaskitPackages = false) => {
|
|
|
4
4
|
};
|
|
5
5
|
export const isPackageFromSupportedScopes = (packageName, supportedScopes = defaultScopes) => {
|
|
6
6
|
return supportedScopes.some(scope => packageName.startsWith(scope));
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* Checks if the package is from supported scope
|
|
12
|
-
* and if so, the package is also from supported package list.
|
|
13
|
-
*/
|
|
14
|
-
export const isPackageSupported = (packageName, supportedPackages = [], supportedScopes = defaultScopes) => {
|
|
15
|
-
if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
|
|
16
|
-
return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
7
|
};
|
|
@@ -11,15 +11,12 @@ export const generateCSV = packageChanges => {
|
|
|
11
11
|
if (depColumnIndex === -1) {
|
|
12
12
|
depColumnIndex = csvData.push([name]) - 1;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
// console.log(csvData)
|
|
16
14
|
csvData[depColumnIndex][currentRow] = version;
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
17
|
for (let i = 0; i < csvData.length; i++) {
|
|
20
18
|
for (let j = 0; j < csvData.length; j++) {
|
|
21
19
|
if (typeof csvData[i][j] !== 'string') {
|
|
22
|
-
// console.log('found empty cell');
|
|
23
20
|
csvData[i][j] = '';
|
|
24
21
|
}
|
|
25
22
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
// @ts-ignore
|
|
3
2
|
import inquirer from 'inquirer';
|
|
4
3
|
import semver from 'semver';
|
|
5
4
|
/* eslint-disable-next-line import/no-unresolved */
|
|
@@ -60,7 +59,7 @@ export function createUpgradeEvent(name, version, previousVersion, date, optiona
|
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
61
|
return {
|
|
63
|
-
cliVersion: "1.4.
|
|
62
|
+
cliVersion: "1.4.8",
|
|
64
63
|
dependencyName: name,
|
|
65
64
|
versionString: eventVersion,
|
|
66
65
|
major: parsedVersion ? `${parsedVersion.major}` : null,
|
package/dist/es2019/util/git.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
|
|
3
1
|
import git from 'simple-git';
|
|
4
2
|
import { assert } from './assert';
|
|
5
3
|
export async function getChangesSince(since) {
|
|
@@ -15,7 +13,7 @@ export async function getChangesSince(since) {
|
|
|
15
13
|
'--stat=4096',
|
|
16
14
|
// Make +- graph width as small as possible to maximise filename length
|
|
17
15
|
'--stat-graph-width=1', ...revisionRange,
|
|
18
|
-
// Any commit that modifies a package.json
|
|
16
|
+
// Any commit that modifies a package.json in any directory
|
|
19
17
|
':(glob)**/package.json']);
|
|
20
18
|
return {
|
|
21
19
|
...listLogSummary,
|
package/dist/es2019/util/yarn.js
CHANGED
|
@@ -4,10 +4,10 @@ import micromatch from 'micromatch';
|
|
|
4
4
|
import * as git from './git';
|
|
5
5
|
const rootPackageJsonPath = 'package.json';
|
|
6
6
|
const debug = debugModule('atlaskit:yarn');
|
|
7
|
-
export async function
|
|
7
|
+
export async function getWorkspacePackageJsonPaths(hash, cwd) {
|
|
8
8
|
let file;
|
|
9
9
|
try {
|
|
10
|
-
file = await git.showFile(
|
|
10
|
+
file = await git.showFile(hash, rootPackageJsonPath, {
|
|
11
11
|
cwd
|
|
12
12
|
});
|
|
13
13
|
} catch (e) {
|
|
@@ -18,7 +18,7 @@ export async function getWorkspaceGlobs(ref, cwd) {
|
|
|
18
18
|
try {
|
|
19
19
|
rootPackageJsonFile = JSON.parse(file);
|
|
20
20
|
} catch (e) {
|
|
21
|
-
console.error(`Error parsing ${file}@${
|
|
21
|
+
console.error(`Error parsing ${file}@${hash}: ${e}`);
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
const workspaces = rootPackageJsonFile.workspaces;
|
|
@@ -14,12 +14,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
14
14
|
|
|
15
15
|
import debugModule from 'debug';
|
|
16
16
|
import semver from 'semver';
|
|
17
|
-
import { getWorkspacePaths,
|
|
17
|
+
import { getWorkspacePaths, getWorkspacePackageJsonPaths } from '../../../util/yarn';
|
|
18
18
|
import { showFile } from '../../../util/git';
|
|
19
19
|
import { DEP_TYPES } from '../../../constants';
|
|
20
20
|
import { assert } from '../../../util/assert';
|
|
21
21
|
import micromatch from 'micromatch';
|
|
22
|
-
import {
|
|
22
|
+
import { isPackageFromSupportedScopes } from '../util/allowed-scopes';
|
|
23
23
|
var debug = debugModule('atlaskit:dependency');
|
|
24
24
|
/**
|
|
25
25
|
* Stores the state of atlaskit dependencies in a repository
|
|
@@ -34,8 +34,8 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
34
34
|
_defineProperty(this, "dependencies", {});
|
|
35
35
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
36
36
|
_defineProperty(this, "workspaces", {});
|
|
37
|
-
/** Set of workspace
|
|
38
|
-
_defineProperty(this, "
|
|
37
|
+
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
38
|
+
_defineProperty(this, "workspacePackageJsonPaths", new Set());
|
|
39
39
|
_defineProperty(this, "initialised", false);
|
|
40
40
|
this.cwd = cwd;
|
|
41
41
|
this.supportedScopes = supportedScopes;
|
|
@@ -77,7 +77,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
77
77
|
key: "update",
|
|
78
78
|
value: function () {
|
|
79
79
|
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(logItem) {
|
|
80
|
-
var hash, changedPackageJsons, didRootPackageJsonChange,
|
|
80
|
+
var hash, changedPackageJsons, didRootPackageJsonChange, workspacePackageJsonPaths, workspacePackageJsonPathsChanged, changedWorkspaces, _iterator, _step, workspacePath, workspaceDeps, validWorkspace, noLongerWorkspace;
|
|
81
81
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
82
82
|
while (1) switch (_context2.prev = _context2.next) {
|
|
83
83
|
case 0:
|
|
@@ -85,7 +85,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
85
85
|
hash = logItem.hash;
|
|
86
86
|
assert(!!logItem.diff, "Diff must exist in log ".concat(logItem, " ").concat(hash));
|
|
87
87
|
changedPackageJsons = logItem.diff.files.filter(function (f) {
|
|
88
|
-
return f.file
|
|
88
|
+
return f.file.endsWith('package.json');
|
|
89
89
|
}).map(function (f) {
|
|
90
90
|
return f.file;
|
|
91
91
|
});
|
|
@@ -97,23 +97,23 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
97
97
|
break;
|
|
98
98
|
}
|
|
99
99
|
_context2.next = 8;
|
|
100
|
-
return
|
|
100
|
+
return getWorkspacePackageJsonPaths(hash, this.cwd);
|
|
101
101
|
case 8:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return !
|
|
102
|
+
workspacePackageJsonPaths = _context2.sent;
|
|
103
|
+
workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || _toConsumableArray(this.workspacePackageJsonPaths).some(function (glob) {
|
|
104
|
+
return !workspacePackageJsonPaths.has(glob);
|
|
105
105
|
}));
|
|
106
|
-
if (!
|
|
106
|
+
if (!workspacePackageJsonPathsChanged) {
|
|
107
107
|
_context2.next = 15;
|
|
108
108
|
break;
|
|
109
109
|
}
|
|
110
|
-
debug("Workspace globs changed: ".concat(_toConsumableArray(
|
|
110
|
+
debug("Workspace globs changed: ".concat(_toConsumableArray(workspacePackageJsonPaths), ". Resetting store."));
|
|
111
111
|
_context2.next = 14;
|
|
112
112
|
return this.resetStore(hash);
|
|
113
113
|
case 14:
|
|
114
114
|
return _context2.abrupt("return", this.getFlattenedDeps());
|
|
115
115
|
case 15:
|
|
116
|
-
changedWorkspaces = micromatch(changedPackageJsons, _toConsumableArray(this.
|
|
116
|
+
changedWorkspaces = micromatch(changedPackageJsons, _toConsumableArray(this.workspacePackageJsonPaths));
|
|
117
117
|
debug("Updating changed workspaces@".concat(hash, ": ").concat(changedWorkspaces));
|
|
118
118
|
|
|
119
119
|
// Iterate over all changed package.jsons rather than only valid workspaces so that we can
|
|
@@ -194,7 +194,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
194
194
|
versions = _ref4[1];
|
|
195
195
|
return [depName, DependencyStore.getMinimumVersion(versions, depName)];
|
|
196
196
|
});
|
|
197
|
-
return fromEntries(deps);
|
|
197
|
+
return Object.fromEntries(deps);
|
|
198
198
|
}
|
|
199
199
|
}, {
|
|
200
200
|
key: "assertInitialised",
|
|
@@ -208,7 +208,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
208
208
|
}, {
|
|
209
209
|
key: "resetStore",
|
|
210
210
|
value: function () {
|
|
211
|
-
var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(
|
|
211
|
+
var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(hash) {
|
|
212
212
|
var workspaceGlobs, workspacePaths, _iterator2, _step2, wsPath, workspaceDeps;
|
|
213
213
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
214
214
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -216,14 +216,14 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
216
216
|
this.dependencies = {};
|
|
217
217
|
this.workspaces = {};
|
|
218
218
|
_context3.next = 4;
|
|
219
|
-
return
|
|
219
|
+
return getWorkspacePackageJsonPaths(hash, this.cwd);
|
|
220
220
|
case 4:
|
|
221
221
|
workspaceGlobs = _context3.sent;
|
|
222
222
|
if (workspaceGlobs !== null) {
|
|
223
|
-
this.
|
|
223
|
+
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
224
224
|
}
|
|
225
225
|
_context3.next = 8;
|
|
226
|
-
return getWorkspacePaths(
|
|
226
|
+
return getWorkspacePaths(hash, this.workspacePackageJsonPaths, this.cwd);
|
|
227
227
|
case 8:
|
|
228
228
|
workspacePaths = _context3.sent;
|
|
229
229
|
debug("Workspace paths: ".concat(workspacePaths));
|
|
@@ -243,7 +243,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
243
243
|
throw new Error("Duplicate workspace path found: ".concat(wsPath));
|
|
244
244
|
case 17:
|
|
245
245
|
_context3.next = 19;
|
|
246
|
-
return this.getWorkspaceDependencies(
|
|
246
|
+
return this.getWorkspaceDependencies(hash, wsPath);
|
|
247
247
|
case 19:
|
|
248
248
|
workspaceDeps = _context3.sent;
|
|
249
249
|
if (!(workspaceDeps == null)) {
|
|
@@ -406,23 +406,40 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
406
406
|
}
|
|
407
407
|
}, {
|
|
408
408
|
key: "getSupportedDependencies",
|
|
409
|
-
value: function getSupportedDependencies(depMap,
|
|
409
|
+
value: function getSupportedDependencies(depMap, dependencyType) {
|
|
410
410
|
var _this = this;
|
|
411
|
-
return
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
411
|
+
return Object.entries(depMap).reduce(function (supportedDependencies, _ref5) {
|
|
412
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
413
|
+
rawPackageName = _ref6[0],
|
|
414
|
+
packageVersion = _ref6[1];
|
|
415
|
+
// Ignore suffixed `--next` deps in jira used for independent upgrades
|
|
416
|
+
if (rawPackageName.endsWith('--next')) {
|
|
417
|
+
return supportedDependencies;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Treat `--current` as the standard dependency
|
|
421
|
+
var packageName = rawPackageName.replace(/--current$/, '');
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Checks if the package is from supported scope
|
|
425
|
+
* and if so, checks if the package is also from supported package list.
|
|
426
|
+
*/
|
|
427
|
+
var isPackageSupported = isPackageFromSupportedScopes(packageName, _this.supportedScopes) && (
|
|
428
|
+
// If supportedPackages wasn't specified, then we allow ANY packages
|
|
429
|
+
!_this.supportedPackages.length ||
|
|
430
|
+
/**
|
|
431
|
+
* All packageName's formatting, such as removing "--current" postfix, MUST be performed BEFORE the next line
|
|
432
|
+
* Packages in supportedPackages don't have postfixes, so checking for package with postfix will always return false
|
|
433
|
+
*/
|
|
434
|
+
_this.supportedPackages.includes(packageName));
|
|
435
|
+
if (isPackageSupported) {
|
|
436
|
+
supportedDependencies[packageName] = {
|
|
437
|
+
version: DependencyStore.transformDepVersion(packageVersion),
|
|
438
|
+
type: dependencyType
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
return supportedDependencies;
|
|
442
|
+
}, {});
|
|
426
443
|
}
|
|
427
444
|
}], [{
|
|
428
445
|
key: "getMinimumVersion",
|
|
@@ -454,12 +471,6 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
454
471
|
}
|
|
455
472
|
return sorted[0];
|
|
456
473
|
}
|
|
457
|
-
}, {
|
|
458
|
-
key: "transformDepName",
|
|
459
|
-
value: function transformDepName(name) {
|
|
460
|
-
// Treat `--current` as the standard dependency
|
|
461
|
-
return name.replace(/--current$/, '');
|
|
462
|
-
}
|
|
463
474
|
|
|
464
475
|
/* Coerce non-standard versions to a semver version.
|
|
465
476
|
* This essentially ignores everything up until the first number and then tries to parse a version
|
|
@@ -474,13 +485,4 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
474
485
|
}
|
|
475
486
|
}]);
|
|
476
487
|
return DependencyStore;
|
|
477
|
-
}();
|
|
478
|
-
|
|
479
|
-
// Object.fromEntries polyfill, remove when upgraded to node 10
|
|
480
|
-
function fromEntries(iterable) {
|
|
481
|
-
return _toConsumableArray(iterable).reduce(function (obj, _ref9) {
|
|
482
|
-
var key = _ref9[0],
|
|
483
|
-
val = _ref9[1];
|
|
484
|
-
return Object.assign(obj, _defineProperty({}, key, val));
|
|
485
|
-
}, {});
|
|
486
|
-
}
|
|
488
|
+
}();
|
|
@@ -8,18 +8,4 @@ export var isPackageFromSupportedScopes = function isPackageFromSupportedScopes(
|
|
|
8
8
|
return supportedScopes.some(function (scope) {
|
|
9
9
|
return packageName.startsWith(scope);
|
|
10
10
|
});
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Checks if the package is from supported scope
|
|
16
|
-
* and if so, the package is also from supported package list.
|
|
17
|
-
*/
|
|
18
|
-
export var isPackageSupported = function isPackageSupported(packageName) {
|
|
19
|
-
var supportedPackages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
20
|
-
var supportedScopes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultScopes;
|
|
21
|
-
if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
|
|
22
|
-
return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
11
|
};
|
|
@@ -15,15 +15,12 @@ export var generateCSV = function generateCSV(packageChanges) {
|
|
|
15
15
|
if (depColumnIndex === -1) {
|
|
16
16
|
depColumnIndex = csvData.push([name]) - 1;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
// console.log(csvData)
|
|
20
18
|
csvData[depColumnIndex][currentRow] = version;
|
|
21
19
|
});
|
|
22
20
|
});
|
|
23
21
|
for (var i = 0; i < csvData.length; i++) {
|
|
24
22
|
for (var j = 0; j < csvData.length; j++) {
|
|
25
23
|
if (typeof csvData[i][j] !== 'string') {
|
|
26
|
-
// console.log('found empty cell');
|
|
27
24
|
csvData[i][j] = '';
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -4,7 +4,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
import chalk from 'chalk';
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
import inquirer from 'inquirer';
|
|
9
8
|
import semver from 'semver';
|
|
10
9
|
/* eslint-disable-next-line import/no-unresolved */
|
|
@@ -67,7 +66,7 @@ export function createUpgradeEvent(name, version, previousVersion, date) {
|
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
return _objectSpread({
|
|
70
|
-
cliVersion: "1.4.
|
|
69
|
+
cliVersion: "1.4.8",
|
|
71
70
|
dependencyName: name,
|
|
72
71
|
versionString: eventVersion,
|
|
73
72
|
major: parsedVersion ? "".concat(parsedVersion.major) : null,
|
package/dist/esm/util/git.js
CHANGED
|
@@ -4,8 +4,6 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
|
|
9
7
|
import git from 'simple-git';
|
|
10
8
|
import { assert } from './assert';
|
|
11
9
|
export function getChangesSince(_x) {
|
|
@@ -30,7 +28,7 @@ function _getChangesSince() {
|
|
|
30
28
|
'--stat=4096',
|
|
31
29
|
// Make +- graph width as small as possible to maximise filename length
|
|
32
30
|
'--stat-graph-width=1'].concat(revisionRange, [
|
|
33
|
-
// Any commit that modifies a package.json
|
|
31
|
+
// Any commit that modifies a package.json in any directory
|
|
34
32
|
':(glob)**/package.json']));
|
|
35
33
|
case 3:
|
|
36
34
|
listLogSummary = _context.sent;
|
package/dist/esm/util/yarn.js
CHANGED
|
@@ -7,18 +7,18 @@ import micromatch from 'micromatch';
|
|
|
7
7
|
import * as git from './git';
|
|
8
8
|
var rootPackageJsonPath = 'package.json';
|
|
9
9
|
var debug = debugModule('atlaskit:yarn');
|
|
10
|
-
export function
|
|
11
|
-
return
|
|
10
|
+
export function getWorkspacePackageJsonPaths(_x, _x2) {
|
|
11
|
+
return _getWorkspacePackageJsonPaths.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function _getWorkspacePackageJsonPaths() {
|
|
14
|
+
_getWorkspacePackageJsonPaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(hash, cwd) {
|
|
15
15
|
var file, rootPackageJsonFile, workspaces, workspacePackages;
|
|
16
16
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
19
19
|
_context.prev = 0;
|
|
20
20
|
_context.next = 3;
|
|
21
|
-
return git.showFile(
|
|
21
|
+
return git.showFile(hash, rootPackageJsonPath, {
|
|
22
22
|
cwd: cwd
|
|
23
23
|
});
|
|
24
24
|
case 3:
|
|
@@ -38,7 +38,7 @@ function _getWorkspaceGlobs() {
|
|
|
38
38
|
case 14:
|
|
39
39
|
_context.prev = 14;
|
|
40
40
|
_context.t1 = _context["catch"](10);
|
|
41
|
-
console.error("Error parsing ".concat(file, "@").concat(
|
|
41
|
+
console.error("Error parsing ".concat(file, "@").concat(hash, ": ").concat(_context.t1));
|
|
42
42
|
return _context.abrupt("return", null);
|
|
43
43
|
case 18:
|
|
44
44
|
workspaces = rootPackageJsonFile.workspaces;
|
|
@@ -59,7 +59,7 @@ function _getWorkspaceGlobs() {
|
|
|
59
59
|
}
|
|
60
60
|
}, _callee, null, [[0, 6], [10, 14]]);
|
|
61
61
|
}));
|
|
62
|
-
return
|
|
62
|
+
return _getWorkspacePackageJsonPaths.apply(this, arguments);
|
|
63
63
|
}
|
|
64
64
|
export function getWorkspacePaths(_x3, _x4, _x5) {
|
|
65
65
|
return _getWorkspacePaths.apply(this, arguments);
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { LogResult } from 'simple-git';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const generateLogsWithFiles: (list: {
|
|
3
|
+
hash: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
}[]) => LogResult;
|
|
6
|
+
export declare const generateLogs: (...hashList: string[]) => LogResult;
|
|
@@ -10,14 +10,14 @@ export declare class DependencyStore {
|
|
|
10
10
|
private dependencies;
|
|
11
11
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
12
12
|
private workspaces;
|
|
13
|
-
/** Set of workspace
|
|
14
|
-
private
|
|
13
|
+
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
14
|
+
private workspacePackageJsonPaths;
|
|
15
15
|
private initialised;
|
|
16
16
|
private supportedScopes;
|
|
17
17
|
private supportedPackages;
|
|
18
18
|
constructor(cwd: string | undefined, supportedScopes: string[], supportedPackages: string[]);
|
|
19
19
|
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
20
|
-
initialise(gitRef
|
|
20
|
+
initialise(gitRef?: string): Promise<DependencyMap>;
|
|
21
21
|
/** Updates the repo dependency store based on the changes in `logItem`.
|
|
22
22
|
* Returns the updated flattened dependencies
|
|
23
23
|
*/
|
|
@@ -36,6 +36,5 @@ export declare class DependencyStore {
|
|
|
36
36
|
private removeDependency;
|
|
37
37
|
private getSupportedDependencies;
|
|
38
38
|
private static getMinimumVersion;
|
|
39
|
-
private static transformDepName;
|
|
40
39
|
private static transformDepVersion;
|
|
41
40
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
export declare const getSupportedScopes: (enableNonAtlaskitPackages?: boolean) => string[];
|
|
2
2
|
export declare const isPackageFromSupportedScopes: (packageName: string, supportedScopes?: string[]) => boolean;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Checks if the package is from supported scope
|
|
6
|
-
* and if so, the package is also from supported package list.
|
|
7
|
-
*/
|
|
8
|
-
export declare const isPackageSupported: (packageName: string, supportedPackages?: string[], supportedScopes?: string[]) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getWorkspacePackageJsonPaths(hash: string, cwd: string): Promise<Set<string> | null>;
|
|
2
2
|
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string>, cwd: string): Promise<string[]>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { LogResult } from 'simple-git';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const generateLogsWithFiles: (list: {
|
|
3
|
+
hash: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
}[]) => LogResult;
|
|
6
|
+
export declare const generateLogs: (...hashList: string[]) => LogResult;
|
|
@@ -10,14 +10,14 @@ export declare class DependencyStore {
|
|
|
10
10
|
private dependencies;
|
|
11
11
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
12
12
|
private workspaces;
|
|
13
|
-
/** Set of workspace
|
|
14
|
-
private
|
|
13
|
+
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
14
|
+
private workspacePackageJsonPaths;
|
|
15
15
|
private initialised;
|
|
16
16
|
private supportedScopes;
|
|
17
17
|
private supportedPackages;
|
|
18
18
|
constructor(cwd: string | undefined, supportedScopes: string[], supportedPackages: string[]);
|
|
19
19
|
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
20
|
-
initialise(gitRef
|
|
20
|
+
initialise(gitRef?: string): Promise<DependencyMap>;
|
|
21
21
|
/** Updates the repo dependency store based on the changes in `logItem`.
|
|
22
22
|
* Returns the updated flattened dependencies
|
|
23
23
|
*/
|
|
@@ -36,6 +36,5 @@ export declare class DependencyStore {
|
|
|
36
36
|
private removeDependency;
|
|
37
37
|
private getSupportedDependencies;
|
|
38
38
|
private static getMinimumVersion;
|
|
39
|
-
private static transformDepName;
|
|
40
39
|
private static transformDepVersion;
|
|
41
40
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
export declare const getSupportedScopes: (enableNonAtlaskitPackages?: boolean) => string[];
|
|
2
2
|
export declare const isPackageFromSupportedScopes: (packageName: string, supportedScopes?: string[]) => boolean;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* Checks if the package is from supported scope
|
|
6
|
-
* and if so, the package is also from supported package list.
|
|
7
|
-
*/
|
|
8
|
-
export declare const isPackageSupported: (packageName: string, supportedPackages?: string[], supportedScopes?: string[]) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getWorkspacePackageJsonPaths(hash: string, cwd: string): Promise<Set<string> | null>;
|
|
2
2
|
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string>, cwd: string): Promise<string[]>;
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dependency-version-analytics",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"description": "Tool to pull atlaskit version history from a repo",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"bin": {
|
|
29
29
|
"dependency-version-analytics": "./bin/dependency-version-analytics.js"
|
|
30
30
|
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "jest"
|
|
33
|
+
},
|
|
31
34
|
"dependencies": {
|
|
32
35
|
"@babel/runtime": "^7.0.0",
|
|
33
36
|
"chalk": "^4.1.2",
|
|
@@ -48,6 +51,8 @@
|
|
|
48
51
|
"@types/jest": "^26.0.14",
|
|
49
52
|
"@types/micromatch": "^4.0.1",
|
|
50
53
|
"@types/node": "~16.11.27",
|
|
54
|
+
"jest": "^26.4.2",
|
|
55
|
+
"ts-jest": "26.5.6",
|
|
51
56
|
"ts-node": "^10.9.1",
|
|
52
57
|
"typescript": "~4.9.5"
|
|
53
58
|
},
|