@atlaskit/dependency-version-analytics 1.5.1 → 1.6.1
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 +12 -0
- package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +16 -8
- package/dist/cjs/commands/populate-historic-data/product.js +13 -13
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/cjs/util/yarn.js +9 -12
- package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +15 -8
- package/dist/es2019/commands/populate-historic-data/product.js +13 -13
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/es2019/util/yarn.js +9 -12
- package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +25 -22
- package/dist/esm/commands/populate-historic-data/product.js +44 -39
- package/dist/esm/util/analytics.js +1 -1
- package/dist/esm/util/yarn.js +29 -32
- package/dist/types/commands/populate-historic-data/lib/dependency-store.d.ts +11 -2
- package/dist/types/commands/populate-historic-data/product.d.ts +1 -0
- package/dist/types/util/yarn.d.ts +2 -2
- package/dist/types-ts4.5/commands/populate-historic-data/lib/dependency-store.d.ts +11 -2
- package/dist/types-ts4.5/commands/populate-historic-data/product.d.ts +1 -0
- package/dist/types-ts4.5/util/yarn.d.ts +2 -2
- package/package.json +1 -1
- package/report.api.md +1 -0
- package/tmp/api-report-tmp.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/dependency-version-analytics
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1d902045dff`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1d902045dff) - Skip alpha versions packages
|
|
8
|
+
|
|
9
|
+
## 1.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`d6cf767ff5e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d6cf767ff5e) - Use subWorkDir flag to get root package.json
|
|
14
|
+
|
|
3
15
|
## 1.5.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -20,6 +20,12 @@ const debug = (0, _debug.default)('atlaskit:dependency');
|
|
|
20
20
|
* Stores the state of atlaskit dependencies in a repository
|
|
21
21
|
*/
|
|
22
22
|
class DependencyStore {
|
|
23
|
+
/**
|
|
24
|
+
* We may want to work not in root, but in specific directory
|
|
25
|
+
* The reason is - some repositories have their package.json not in root
|
|
26
|
+
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
27
|
+
*/
|
|
28
|
+
|
|
23
29
|
/** Mapping of dependency names to arrays of unique dependency type + versions */
|
|
24
30
|
dependencies = {};
|
|
25
31
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
@@ -27,8 +33,12 @@ class DependencyStore {
|
|
|
27
33
|
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
28
34
|
workspacePackageJsonPaths = new Set();
|
|
29
35
|
initialised = false;
|
|
30
|
-
constructor(
|
|
31
|
-
|
|
36
|
+
constructor({
|
|
37
|
+
subWorkDir,
|
|
38
|
+
supportedScopes,
|
|
39
|
+
supportedPackages
|
|
40
|
+
}) {
|
|
41
|
+
this.subWorkDir = subWorkDir;
|
|
32
42
|
this.supportedScopes = supportedScopes;
|
|
33
43
|
this.supportedPackages = supportedPackages;
|
|
34
44
|
}
|
|
@@ -52,7 +62,7 @@ class DependencyStore {
|
|
|
52
62
|
const changedPackageJsons = logItem.diff.files.filter(f => f.file.endsWith('package.json')).map(f => f.file);
|
|
53
63
|
const didRootPackageJsonChange = !!changedPackageJsons.find(file => file === 'package.json');
|
|
54
64
|
if (didRootPackageJsonChange) {
|
|
55
|
-
const workspacePackageJsonPaths = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.
|
|
65
|
+
const workspacePackageJsonPaths = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.subWorkDir);
|
|
56
66
|
const workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || [...this.workspacePackageJsonPaths].some(glob => !workspacePackageJsonPaths.has(glob)));
|
|
57
67
|
if (workspacePackageJsonPathsChanged) {
|
|
58
68
|
debug(`Workspace globs changed: ${[...workspacePackageJsonPaths]}. Resetting store.`);
|
|
@@ -107,11 +117,11 @@ class DependencyStore {
|
|
|
107
117
|
async resetStore(hash) {
|
|
108
118
|
this.dependencies = {};
|
|
109
119
|
this.workspaces = {};
|
|
110
|
-
const workspaceGlobs = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.
|
|
120
|
+
const workspaceGlobs = await (0, _yarn.getWorkspacePackageJsonPaths)(hash, this.subWorkDir);
|
|
111
121
|
if (workspaceGlobs !== null) {
|
|
112
122
|
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
113
123
|
}
|
|
114
|
-
const workspacePaths = await (0, _yarn.getWorkspacePaths)(hash, this.workspacePackageJsonPaths
|
|
124
|
+
const workspacePaths = await (0, _yarn.getWorkspacePaths)(hash, this.workspacePackageJsonPaths);
|
|
115
125
|
debug(`Workspace paths: ${workspacePaths}`);
|
|
116
126
|
for (const wsPath of workspacePaths) {
|
|
117
127
|
if (this.workspaces[wsPath]) {
|
|
@@ -127,9 +137,7 @@ class DependencyStore {
|
|
|
127
137
|
async getWorkspaceDependencies(hash, workspacePath) {
|
|
128
138
|
let file;
|
|
129
139
|
try {
|
|
130
|
-
file = await (0, _git.showFile)(hash, workspacePath
|
|
131
|
-
cwd: this.cwd
|
|
132
|
-
});
|
|
140
|
+
file = await (0, _git.showFile)(hash, workspacePath);
|
|
133
141
|
} catch (e) {
|
|
134
142
|
debug(`Could not show file ${workspacePath}@${hash}`);
|
|
135
143
|
return null;
|
|
@@ -20,7 +20,9 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
|
|
|
20
20
|
date,
|
|
21
21
|
commitHash
|
|
22
22
|
}) => {
|
|
23
|
-
const addOrUpgradeEvents = Object.entries(newDeps).
|
|
23
|
+
const addOrUpgradeEvents = Object.entries(newDeps).filter(([, {
|
|
24
|
+
version
|
|
25
|
+
}]) => !version.includes('alpha')).map(([name, {
|
|
24
26
|
version,
|
|
25
27
|
type
|
|
26
28
|
}]) => {
|
|
@@ -50,13 +52,15 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
|
|
|
50
52
|
}).filter(e => e != null);
|
|
51
53
|
return [...addOrUpgradeEvents, ...removeEvents];
|
|
52
54
|
};
|
|
53
|
-
const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
|
|
54
|
-
cwd
|
|
55
|
-
}, supportedScopes, supportedPackages) => {
|
|
55
|
+
const getEventsFromHistory = async (packageChangesLog, prevRunHash, directoryOptions, supportedScopes, supportedPackages) => {
|
|
56
56
|
const allPackageChanges = [];
|
|
57
57
|
let allUpgradeEvents = [];
|
|
58
58
|
(0, _assert.assert)(packageChangesLog.all.length > 0, '');
|
|
59
|
-
let dependencyStore = new _dependencyStore.DependencyStore(
|
|
59
|
+
let dependencyStore = new _dependencyStore.DependencyStore({
|
|
60
|
+
...directoryOptions,
|
|
61
|
+
supportedScopes,
|
|
62
|
+
supportedPackages
|
|
63
|
+
});
|
|
60
64
|
let dependencies = await dependencyStore.initialise(prevRunHash);
|
|
61
65
|
for (let i = 0; i < packageChangesLog.all.length; i++) {
|
|
62
66
|
let item = packageChangesLog.all[i];
|
|
@@ -99,14 +103,10 @@ async function getSinceRef(flags) {
|
|
|
99
103
|
return tag;
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
const getWorkDir = cwd => {
|
|
103
|
-
const workDir = cwd ?? process.cwd();
|
|
104
|
-
// Make sure that we're working in needed directory
|
|
105
|
-
process.chdir(workDir);
|
|
106
|
-
return workDir;
|
|
107
|
-
};
|
|
108
106
|
async function populateProduct(flags) {
|
|
109
|
-
|
|
107
|
+
if (flags.cwd) {
|
|
108
|
+
process.chdir(flags.cwd);
|
|
109
|
+
}
|
|
110
110
|
const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
|
|
111
111
|
const log = await (0, _git.getChangesSince)(sinceRef);
|
|
112
112
|
const supportedScopes = (0, _allowedScopes.getSupportedScopes)(flags.includeRestrictedScopes);
|
|
@@ -120,7 +120,7 @@ async function populateProduct(flags) {
|
|
|
120
120
|
allPackageChanges,
|
|
121
121
|
allUpgradeEvents
|
|
122
122
|
} = await getEventsFromHistory(log, sinceRef, {
|
|
123
|
-
|
|
123
|
+
subWorkDir: flags.subWorkDir
|
|
124
124
|
}, supportedScopes, supportedPackages);
|
|
125
125
|
if (!allUpgradeEvents.length) {
|
|
126
126
|
console.log(`Found no dependency changes from supported scopes ${supportedScopes.join(', ')} since last run from ref "${sinceRef}"'`);
|
|
@@ -67,7 +67,7 @@ function createUpgradeEvent(name, version, previousVersion, date, optionalEventA
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
return {
|
|
70
|
-
cliVersion: "1.
|
|
70
|
+
cliVersion: "1.6.1",
|
|
71
71
|
dependencyName: name,
|
|
72
72
|
versionString: eventVersion,
|
|
73
73
|
major: parsedVersion ? `${parsedVersion.major}` : null,
|
package/dist/cjs/util/yarn.js
CHANGED
|
@@ -13,19 +13,18 @@ var git = _interopRequireWildcard(require("./git"));
|
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
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 debug = (0, _debug.default)('atlaskit:yarn');
|
|
16
|
-
async function getWorkspacePackageJsonPaths(hash,
|
|
16
|
+
async function getWorkspacePackageJsonPaths(hash, subWorkDir) {
|
|
17
17
|
let file;
|
|
18
|
+
const rootPackageJson = `${subWorkDir ? `${subWorkDir}/` : ''}package.json`;
|
|
18
19
|
try {
|
|
19
20
|
/**
|
|
20
21
|
* We need to use package.json from current working directory, not from root
|
|
21
22
|
* The reason is - some repositories have their package.json not in root
|
|
22
23
|
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
23
24
|
*/
|
|
24
|
-
file = await git.showFile(hash,
|
|
25
|
-
cwd
|
|
26
|
-
});
|
|
25
|
+
file = await git.showFile(hash, rootPackageJson);
|
|
27
26
|
} catch (error) {
|
|
28
|
-
const errorMessage = `File by hash "${hash}" and path "${
|
|
27
|
+
const errorMessage = `File by hash "${hash}" and path "${rootPackageJson}" does not exist`;
|
|
29
28
|
debug(errorMessage, {
|
|
30
29
|
error
|
|
31
30
|
});
|
|
@@ -41,22 +40,20 @@ async function getWorkspacePackageJsonPaths(hash, cwd) {
|
|
|
41
40
|
}
|
|
42
41
|
const workspaces = rootPackageJsonFile.workspaces;
|
|
43
42
|
if (!workspaces) {
|
|
44
|
-
return new Set([
|
|
43
|
+
return new Set([rootPackageJson]);
|
|
45
44
|
}
|
|
46
45
|
// There are actually two formats for workspaces and they are poorly documented
|
|
47
46
|
const workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
|
|
48
|
-
return new Set([
|
|
47
|
+
return new Set([rootPackageJson, ...workspacePackages.map(glob => _path.default.join(glob, 'package.json'))]);
|
|
49
48
|
}
|
|
50
|
-
async function getWorkspacePaths(ref, workspaceGlobs
|
|
49
|
+
async function getWorkspacePaths(ref, workspaceGlobs) {
|
|
51
50
|
if (workspaceGlobs.size === 0) {
|
|
52
51
|
return [];
|
|
53
52
|
}
|
|
54
|
-
const workspacePackageJsons = await git.getFiles(ref, '**/package.json'
|
|
55
|
-
cwd
|
|
56
|
-
});
|
|
53
|
+
const workspacePackageJsons = await git.getFiles(ref, '**/package.json');
|
|
57
54
|
const matchedWorkspaces = (0, _micromatch.default)(workspacePackageJsons, [...workspaceGlobs]);
|
|
58
55
|
if (matchedWorkspaces.length === 0) {
|
|
59
|
-
throw new Error(`Could not find any workspace or package.json under "${cwd}" for "${ref}" tag`);
|
|
56
|
+
throw new Error(`Could not find any workspace or package.json under "${process.cwd()}" for "${ref}" tag`);
|
|
60
57
|
}
|
|
61
58
|
return matchedWorkspaces;
|
|
62
59
|
}
|
|
@@ -14,7 +14,16 @@ const debug = debugModule('atlaskit:dependency');
|
|
|
14
14
|
* Stores the state of atlaskit dependencies in a repository
|
|
15
15
|
*/
|
|
16
16
|
export class DependencyStore {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor({
|
|
18
|
+
subWorkDir,
|
|
19
|
+
supportedScopes,
|
|
20
|
+
supportedPackages
|
|
21
|
+
}) {
|
|
22
|
+
/**
|
|
23
|
+
* We may want to work not in root, but in specific directory
|
|
24
|
+
* The reason is - some repositories have their package.json not in root
|
|
25
|
+
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
26
|
+
*/
|
|
18
27
|
/** Mapping of dependency names to arrays of unique dependency type + versions */
|
|
19
28
|
_defineProperty(this, "dependencies", {});
|
|
20
29
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
@@ -22,7 +31,7 @@ export class DependencyStore {
|
|
|
22
31
|
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
23
32
|
_defineProperty(this, "workspacePackageJsonPaths", new Set());
|
|
24
33
|
_defineProperty(this, "initialised", false);
|
|
25
|
-
this.
|
|
34
|
+
this.subWorkDir = subWorkDir;
|
|
26
35
|
this.supportedScopes = supportedScopes;
|
|
27
36
|
this.supportedPackages = supportedPackages;
|
|
28
37
|
}
|
|
@@ -46,7 +55,7 @@ export class DependencyStore {
|
|
|
46
55
|
const changedPackageJsons = logItem.diff.files.filter(f => f.file.endsWith('package.json')).map(f => f.file);
|
|
47
56
|
const didRootPackageJsonChange = !!changedPackageJsons.find(file => file === 'package.json');
|
|
48
57
|
if (didRootPackageJsonChange) {
|
|
49
|
-
const workspacePackageJsonPaths = await getWorkspacePackageJsonPaths(hash, this.
|
|
58
|
+
const workspacePackageJsonPaths = await getWorkspacePackageJsonPaths(hash, this.subWorkDir);
|
|
50
59
|
const workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || [...this.workspacePackageJsonPaths].some(glob => !workspacePackageJsonPaths.has(glob)));
|
|
51
60
|
if (workspacePackageJsonPathsChanged) {
|
|
52
61
|
debug(`Workspace globs changed: ${[...workspacePackageJsonPaths]}. Resetting store.`);
|
|
@@ -101,11 +110,11 @@ export class DependencyStore {
|
|
|
101
110
|
async resetStore(hash) {
|
|
102
111
|
this.dependencies = {};
|
|
103
112
|
this.workspaces = {};
|
|
104
|
-
const workspaceGlobs = await getWorkspacePackageJsonPaths(hash, this.
|
|
113
|
+
const workspaceGlobs = await getWorkspacePackageJsonPaths(hash, this.subWorkDir);
|
|
105
114
|
if (workspaceGlobs !== null) {
|
|
106
115
|
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
107
116
|
}
|
|
108
|
-
const workspacePaths = await getWorkspacePaths(hash, this.workspacePackageJsonPaths
|
|
117
|
+
const workspacePaths = await getWorkspacePaths(hash, this.workspacePackageJsonPaths);
|
|
109
118
|
debug(`Workspace paths: ${workspacePaths}`);
|
|
110
119
|
for (const wsPath of workspacePaths) {
|
|
111
120
|
if (this.workspaces[wsPath]) {
|
|
@@ -121,9 +130,7 @@ export class DependencyStore {
|
|
|
121
130
|
async getWorkspaceDependencies(hash, workspacePath) {
|
|
122
131
|
let file;
|
|
123
132
|
try {
|
|
124
|
-
file = await showFile(hash, workspacePath
|
|
125
|
-
cwd: this.cwd
|
|
126
|
-
});
|
|
133
|
+
file = await showFile(hash, workspacePath);
|
|
127
134
|
} catch (e) {
|
|
128
135
|
debug(`Could not show file ${workspacePath}@${hash}`);
|
|
129
136
|
return null;
|
|
@@ -11,7 +11,9 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
|
|
|
11
11
|
date,
|
|
12
12
|
commitHash
|
|
13
13
|
}) => {
|
|
14
|
-
const addOrUpgradeEvents = Object.entries(newDeps).
|
|
14
|
+
const addOrUpgradeEvents = Object.entries(newDeps).filter(([, {
|
|
15
|
+
version
|
|
16
|
+
}]) => !version.includes('alpha')).map(([name, {
|
|
15
17
|
version,
|
|
16
18
|
type
|
|
17
19
|
}]) => {
|
|
@@ -41,13 +43,15 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
|
|
|
41
43
|
}).filter(e => e != null);
|
|
42
44
|
return [...addOrUpgradeEvents, ...removeEvents];
|
|
43
45
|
};
|
|
44
|
-
const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
|
|
45
|
-
cwd
|
|
46
|
-
}, supportedScopes, supportedPackages) => {
|
|
46
|
+
const getEventsFromHistory = async (packageChangesLog, prevRunHash, directoryOptions, supportedScopes, supportedPackages) => {
|
|
47
47
|
const allPackageChanges = [];
|
|
48
48
|
let allUpgradeEvents = [];
|
|
49
49
|
assert(packageChangesLog.all.length > 0, '');
|
|
50
|
-
let dependencyStore = new DependencyStore(
|
|
50
|
+
let dependencyStore = new DependencyStore({
|
|
51
|
+
...directoryOptions,
|
|
52
|
+
supportedScopes,
|
|
53
|
+
supportedPackages
|
|
54
|
+
});
|
|
51
55
|
let dependencies = await dependencyStore.initialise(prevRunHash);
|
|
52
56
|
for (let i = 0; i < packageChangesLog.all.length; i++) {
|
|
53
57
|
let item = packageChangesLog.all[i];
|
|
@@ -90,14 +94,10 @@ async function getSinceRef(flags) {
|
|
|
90
94
|
return tag;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
const getWorkDir = cwd => {
|
|
94
|
-
const workDir = cwd !== null && cwd !== void 0 ? cwd : process.cwd();
|
|
95
|
-
// Make sure that we're working in needed directory
|
|
96
|
-
process.chdir(workDir);
|
|
97
|
-
return workDir;
|
|
98
|
-
};
|
|
99
97
|
export default async function populateProduct(flags) {
|
|
100
|
-
|
|
98
|
+
if (flags.cwd) {
|
|
99
|
+
process.chdir(flags.cwd);
|
|
100
|
+
}
|
|
101
101
|
const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
|
|
102
102
|
const log = await getChangesSince(sinceRef);
|
|
103
103
|
const supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
|
|
@@ -111,7 +111,7 @@ export default async function populateProduct(flags) {
|
|
|
111
111
|
allPackageChanges,
|
|
112
112
|
allUpgradeEvents
|
|
113
113
|
} = await getEventsFromHistory(log, sinceRef, {
|
|
114
|
-
|
|
114
|
+
subWorkDir: flags.subWorkDir
|
|
115
115
|
}, supportedScopes, supportedPackages);
|
|
116
116
|
if (!allUpgradeEvents.length) {
|
|
117
117
|
console.log(`Found no dependency changes from supported scopes ${supportedScopes.join(', ')} since last run from ref "${sinceRef}"'`);
|
|
@@ -59,7 +59,7 @@ export function createUpgradeEvent(name, version, previousVersion, date, optiona
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
62
|
-
cliVersion: "1.
|
|
62
|
+
cliVersion: "1.6.1",
|
|
63
63
|
dependencyName: name,
|
|
64
64
|
versionString: eventVersion,
|
|
65
65
|
major: parsedVersion ? `${parsedVersion.major}` : null,
|
package/dist/es2019/util/yarn.js
CHANGED
|
@@ -3,19 +3,18 @@ import debugModule from 'debug';
|
|
|
3
3
|
import micromatch from 'micromatch';
|
|
4
4
|
import * as git from './git';
|
|
5
5
|
const debug = debugModule('atlaskit:yarn');
|
|
6
|
-
export async function getWorkspacePackageJsonPaths(hash,
|
|
6
|
+
export async function getWorkspacePackageJsonPaths(hash, subWorkDir) {
|
|
7
7
|
let file;
|
|
8
|
+
const rootPackageJson = `${subWorkDir ? `${subWorkDir}/` : ''}package.json`;
|
|
8
9
|
try {
|
|
9
10
|
/**
|
|
10
11
|
* We need to use package.json from current working directory, not from root
|
|
11
12
|
* The reason is - some repositories have their package.json not in root
|
|
12
13
|
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
13
14
|
*/
|
|
14
|
-
file = await git.showFile(hash,
|
|
15
|
-
cwd
|
|
16
|
-
});
|
|
15
|
+
file = await git.showFile(hash, rootPackageJson);
|
|
17
16
|
} catch (error) {
|
|
18
|
-
const errorMessage = `File by hash "${hash}" and path "${
|
|
17
|
+
const errorMessage = `File by hash "${hash}" and path "${rootPackageJson}" does not exist`;
|
|
19
18
|
debug(errorMessage, {
|
|
20
19
|
error
|
|
21
20
|
});
|
|
@@ -31,22 +30,20 @@ export async function getWorkspacePackageJsonPaths(hash, cwd) {
|
|
|
31
30
|
}
|
|
32
31
|
const workspaces = rootPackageJsonFile.workspaces;
|
|
33
32
|
if (!workspaces) {
|
|
34
|
-
return new Set([
|
|
33
|
+
return new Set([rootPackageJson]);
|
|
35
34
|
}
|
|
36
35
|
// There are actually two formats for workspaces and they are poorly documented
|
|
37
36
|
const workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
|
|
38
|
-
return new Set([
|
|
37
|
+
return new Set([rootPackageJson, ...workspacePackages.map(glob => path.join(glob, 'package.json'))]);
|
|
39
38
|
}
|
|
40
|
-
export async function getWorkspacePaths(ref, workspaceGlobs
|
|
39
|
+
export async function getWorkspacePaths(ref, workspaceGlobs) {
|
|
41
40
|
if (workspaceGlobs.size === 0) {
|
|
42
41
|
return [];
|
|
43
42
|
}
|
|
44
|
-
const workspacePackageJsons = await git.getFiles(ref, '**/package.json'
|
|
45
|
-
cwd
|
|
46
|
-
});
|
|
43
|
+
const workspacePackageJsons = await git.getFiles(ref, '**/package.json');
|
|
47
44
|
const matchedWorkspaces = micromatch(workspacePackageJsons, [...workspaceGlobs]);
|
|
48
45
|
if (matchedWorkspaces.length === 0) {
|
|
49
|
-
throw new Error(`Could not find any workspace or package.json under "${cwd}" for "${ref}" tag`);
|
|
46
|
+
throw new Error(`Could not find any workspace or package.json under "${process.cwd()}" for "${ref}" tag`);
|
|
50
47
|
}
|
|
51
48
|
return matchedWorkspaces;
|
|
52
49
|
}
|
|
@@ -25,11 +25,16 @@ var debug = debugModule('atlaskit:dependency');
|
|
|
25
25
|
* Stores the state of atlaskit dependencies in a repository
|
|
26
26
|
*/
|
|
27
27
|
export var DependencyStore = /*#__PURE__*/function () {
|
|
28
|
-
function DependencyStore() {
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
function DependencyStore(_ref) {
|
|
29
|
+
var subWorkDir = _ref.subWorkDir,
|
|
30
|
+
supportedScopes = _ref.supportedScopes,
|
|
31
|
+
supportedPackages = _ref.supportedPackages;
|
|
32
32
|
_classCallCheck(this, DependencyStore);
|
|
33
|
+
/**
|
|
34
|
+
* We may want to work not in root, but in specific directory
|
|
35
|
+
* The reason is - some repositories have their package.json not in root
|
|
36
|
+
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
37
|
+
*/
|
|
33
38
|
/** Mapping of dependency names to arrays of unique dependency type + versions */
|
|
34
39
|
_defineProperty(this, "dependencies", {});
|
|
35
40
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
@@ -37,7 +42,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
37
42
|
/** Set of workspace paths to their "package.json". Used to verify that a package.json is a valid workspace */
|
|
38
43
|
_defineProperty(this, "workspacePackageJsonPaths", new Set());
|
|
39
44
|
_defineProperty(this, "initialised", false);
|
|
40
|
-
this.
|
|
45
|
+
this.subWorkDir = subWorkDir;
|
|
41
46
|
this.supportedScopes = supportedScopes;
|
|
42
47
|
this.supportedPackages = supportedPackages;
|
|
43
48
|
}
|
|
@@ -97,7 +102,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
97
102
|
break;
|
|
98
103
|
}
|
|
99
104
|
_context2.next = 8;
|
|
100
|
-
return getWorkspacePackageJsonPaths(hash, this.
|
|
105
|
+
return getWorkspacePackageJsonPaths(hash, this.subWorkDir);
|
|
101
106
|
case 8:
|
|
102
107
|
workspacePackageJsonPaths = _context2.sent;
|
|
103
108
|
workspacePackageJsonPathsChanged = workspacePackageJsonPaths !== null && (this.workspacePackageJsonPaths.size !== workspacePackageJsonPaths.size || _toConsumableArray(this.workspacePackageJsonPaths).some(function (glob) {
|
|
@@ -184,14 +189,14 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
184
189
|
}, {
|
|
185
190
|
key: "getFlattenedDeps",
|
|
186
191
|
value: function getFlattenedDeps() {
|
|
187
|
-
var deps = Object.entries(this.dependencies).filter(function (
|
|
188
|
-
var
|
|
189
|
-
versions =
|
|
192
|
+
var deps = Object.entries(this.dependencies).filter(function (_ref2) {
|
|
193
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
194
|
+
versions = _ref3[1];
|
|
190
195
|
return versions.length > 0;
|
|
191
|
-
}).map(function (
|
|
192
|
-
var
|
|
193
|
-
depName =
|
|
194
|
-
versions =
|
|
196
|
+
}).map(function (_ref4) {
|
|
197
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
198
|
+
depName = _ref5[0],
|
|
199
|
+
versions = _ref5[1];
|
|
195
200
|
return [depName, DependencyStore.getMinimumVersion(versions, depName)];
|
|
196
201
|
});
|
|
197
202
|
return Object.fromEntries(deps);
|
|
@@ -216,14 +221,14 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
216
221
|
this.dependencies = {};
|
|
217
222
|
this.workspaces = {};
|
|
218
223
|
_context3.next = 4;
|
|
219
|
-
return getWorkspacePackageJsonPaths(hash, this.
|
|
224
|
+
return getWorkspacePackageJsonPaths(hash, this.subWorkDir);
|
|
220
225
|
case 4:
|
|
221
226
|
workspaceGlobs = _context3.sent;
|
|
222
227
|
if (workspaceGlobs !== null) {
|
|
223
228
|
this.workspacePackageJsonPaths = workspaceGlobs;
|
|
224
229
|
}
|
|
225
230
|
_context3.next = 8;
|
|
226
|
-
return getWorkspacePaths(hash, this.workspacePackageJsonPaths
|
|
231
|
+
return getWorkspacePaths(hash, this.workspacePackageJsonPaths);
|
|
227
232
|
case 8:
|
|
228
233
|
workspacePaths = _context3.sent;
|
|
229
234
|
debug("Workspace paths: ".concat(workspacePaths));
|
|
@@ -288,9 +293,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
288
293
|
case 0:
|
|
289
294
|
_context4.prev = 0;
|
|
290
295
|
_context4.next = 3;
|
|
291
|
-
return showFile(hash, workspacePath
|
|
292
|
-
cwd: this.cwd
|
|
293
|
-
});
|
|
296
|
+
return showFile(hash, workspacePath);
|
|
294
297
|
case 3:
|
|
295
298
|
file = _context4.sent;
|
|
296
299
|
_context4.next = 10;
|
|
@@ -408,10 +411,10 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
408
411
|
key: "getSupportedDependencies",
|
|
409
412
|
value: function getSupportedDependencies(depMap, dependencyType) {
|
|
410
413
|
var _this = this;
|
|
411
|
-
return Object.entries(depMap).reduce(function (supportedDependencies,
|
|
412
|
-
var
|
|
413
|
-
rawPackageName =
|
|
414
|
-
packageVersion =
|
|
414
|
+
return Object.entries(depMap).reduce(function (supportedDependencies, _ref6) {
|
|
415
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
416
|
+
rawPackageName = _ref7[0],
|
|
417
|
+
packageVersion = _ref7[1];
|
|
415
418
|
// Ignore suffixed `--next` deps in jira used for independent upgrades
|
|
416
419
|
if (rawPackageName.endsWith('--next')) {
|
|
417
420
|
return supportedDependencies;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
8
|
import { DEFAULT_TAG } from '../../constants';
|
|
6
9
|
import chalk from 'chalk';
|
|
7
10
|
import { createUpgradeEvent, sendAnalytics } from '../../util/analytics';
|
|
@@ -14,12 +17,16 @@ import { getSupportedScopes } from './util/allowed-scopes';
|
|
|
14
17
|
var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDeps, newDeps, _ref) {
|
|
15
18
|
var date = _ref.date,
|
|
16
19
|
commitHash = _ref.commitHash;
|
|
17
|
-
var addOrUpgradeEvents = Object.entries(newDeps).
|
|
20
|
+
var addOrUpgradeEvents = Object.entries(newDeps).filter(function (_ref2) {
|
|
18
21
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
version = _ref3[1].version;
|
|
23
|
+
return !version.includes('alpha');
|
|
24
|
+
}).map(function (_ref4) {
|
|
25
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
26
|
+
name = _ref5[0],
|
|
27
|
+
_ref5$ = _ref5[1],
|
|
28
|
+
version = _ref5$.version,
|
|
29
|
+
type = _ref5$.type;
|
|
23
30
|
var prevDep = oldDeps[name];
|
|
24
31
|
// Only treat a dependency as previous if the dependency type matches
|
|
25
32
|
// Otherwise, we want separate add/remove events
|
|
@@ -32,20 +39,20 @@ var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDe
|
|
|
32
39
|
}).filter(function (e) {
|
|
33
40
|
return e != null;
|
|
34
41
|
});
|
|
35
|
-
var removeEvents = Object.entries(oldDeps).filter(function (
|
|
36
|
-
var
|
|
37
|
-
name =
|
|
38
|
-
type =
|
|
42
|
+
var removeEvents = Object.entries(oldDeps).filter(function (_ref6) {
|
|
43
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
44
|
+
name = _ref7[0],
|
|
45
|
+
type = _ref7[1].type;
|
|
39
46
|
return (
|
|
40
47
|
// Treat the same dep under a different dependency type as a new dep
|
|
41
48
|
newDeps[name] == null || newDeps[name].type !== type
|
|
42
49
|
);
|
|
43
|
-
}).map(function (
|
|
44
|
-
var
|
|
45
|
-
name =
|
|
46
|
-
|
|
47
|
-
version =
|
|
48
|
-
type =
|
|
50
|
+
}).map(function (_ref8) {
|
|
51
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
52
|
+
name = _ref9[0],
|
|
53
|
+
_ref9$ = _ref9[1],
|
|
54
|
+
version = _ref9$.version,
|
|
55
|
+
type = _ref9$.type;
|
|
49
56
|
return createUpgradeEvent(name, undefined, version, date, {
|
|
50
57
|
commitHash: commitHash,
|
|
51
58
|
dependencyType: type,
|
|
@@ -57,33 +64,35 @@ var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDe
|
|
|
57
64
|
return [].concat(_toConsumableArray(addOrUpgradeEvents), _toConsumableArray(removeEvents));
|
|
58
65
|
};
|
|
59
66
|
var getEventsFromHistory = /*#__PURE__*/function () {
|
|
60
|
-
var
|
|
61
|
-
var
|
|
67
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(packageChangesLog, prevRunHash, directoryOptions, supportedScopes, supportedPackages) {
|
|
68
|
+
var allPackageChanges, allUpgradeEvents, dependencyStore, dependencies, i, item, newDependencies, packageChange, upgradeEvents;
|
|
62
69
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
70
|
while (1) switch (_context.prev = _context.next) {
|
|
64
71
|
case 0:
|
|
65
|
-
cwd = _ref8.cwd;
|
|
66
72
|
allPackageChanges = [];
|
|
67
73
|
allUpgradeEvents = [];
|
|
68
74
|
assert(packageChangesLog.all.length > 0, '');
|
|
69
|
-
dependencyStore = new DependencyStore(
|
|
70
|
-
|
|
75
|
+
dependencyStore = new DependencyStore(_objectSpread(_objectSpread({}, directoryOptions), {}, {
|
|
76
|
+
supportedScopes: supportedScopes,
|
|
77
|
+
supportedPackages: supportedPackages
|
|
78
|
+
}));
|
|
79
|
+
_context.next = 6;
|
|
71
80
|
return dependencyStore.initialise(prevRunHash);
|
|
72
|
-
case
|
|
81
|
+
case 6:
|
|
73
82
|
dependencies = _context.sent;
|
|
74
83
|
i = 0;
|
|
75
|
-
case
|
|
84
|
+
case 8:
|
|
76
85
|
if (!(i < packageChangesLog.all.length)) {
|
|
77
|
-
_context.next =
|
|
86
|
+
_context.next = 20;
|
|
78
87
|
break;
|
|
79
88
|
}
|
|
80
89
|
item = packageChangesLog.all[i];
|
|
81
90
|
if (allPackageChanges.length > 0) {
|
|
82
91
|
dependencies = allPackageChanges[allPackageChanges.length - 1].deps;
|
|
83
92
|
}
|
|
84
|
-
_context.next =
|
|
93
|
+
_context.next = 13;
|
|
85
94
|
return dependencyStore.update(item);
|
|
86
|
-
case
|
|
95
|
+
case 13:
|
|
87
96
|
newDependencies = _context.sent;
|
|
88
97
|
packageChange = {
|
|
89
98
|
date: new Date(item.date).toISOString(),
|
|
@@ -97,23 +106,23 @@ var getEventsFromHistory = /*#__PURE__*/function () {
|
|
|
97
106
|
allUpgradeEvents.push.apply(allUpgradeEvents, _toConsumableArray(upgradeEvents));
|
|
98
107
|
allPackageChanges.push(packageChange);
|
|
99
108
|
}
|
|
100
|
-
case
|
|
109
|
+
case 17:
|
|
101
110
|
i++;
|
|
102
|
-
_context.next =
|
|
111
|
+
_context.next = 8;
|
|
103
112
|
break;
|
|
104
|
-
case
|
|
113
|
+
case 20:
|
|
105
114
|
return _context.abrupt("return", {
|
|
106
115
|
allPackageChanges: allPackageChanges,
|
|
107
116
|
allUpgradeEvents: allUpgradeEvents
|
|
108
117
|
});
|
|
109
|
-
case
|
|
118
|
+
case 21:
|
|
110
119
|
case "end":
|
|
111
120
|
return _context.stop();
|
|
112
121
|
}
|
|
113
122
|
}, _callee);
|
|
114
123
|
}));
|
|
115
124
|
return function getEventsFromHistory(_x, _x2, _x3, _x4, _x5) {
|
|
116
|
-
return
|
|
125
|
+
return _ref10.apply(this, arguments);
|
|
117
126
|
};
|
|
118
127
|
}();
|
|
119
128
|
function getSinceRef(_x6) {
|
|
@@ -164,22 +173,18 @@ function _getSinceRef() {
|
|
|
164
173
|
}));
|
|
165
174
|
return _getSinceRef.apply(this, arguments);
|
|
166
175
|
}
|
|
167
|
-
var getWorkDir = function getWorkDir(cwd) {
|
|
168
|
-
var workDir = cwd !== null && cwd !== void 0 ? cwd : process.cwd();
|
|
169
|
-
// Make sure that we're working in needed directory
|
|
170
|
-
process.chdir(workDir);
|
|
171
|
-
return workDir;
|
|
172
|
-
};
|
|
173
176
|
export default function populateProduct(_x7) {
|
|
174
177
|
return _populateProduct.apply(this, arguments);
|
|
175
178
|
}
|
|
176
179
|
function _populateProduct() {
|
|
177
180
|
_populateProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(flags) {
|
|
178
|
-
var
|
|
181
|
+
var sinceRef, log, supportedScopes, supportedPackages, _yield$getEventsFromH, allPackageChanges, allUpgradeEvents, csv, currentCommit;
|
|
179
182
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
180
183
|
while (1) switch (_context3.prev = _context3.next) {
|
|
181
184
|
case 0:
|
|
182
|
-
|
|
185
|
+
if (flags.cwd) {
|
|
186
|
+
process.chdir(flags.cwd);
|
|
187
|
+
}
|
|
183
188
|
if (!flags.reset) {
|
|
184
189
|
_context3.next = 5;
|
|
185
190
|
break;
|
|
@@ -210,7 +215,7 @@ function _populateProduct() {
|
|
|
210
215
|
case 18:
|
|
211
216
|
_context3.next = 20;
|
|
212
217
|
return getEventsFromHistory(log, sinceRef, {
|
|
213
|
-
|
|
218
|
+
subWorkDir: flags.subWorkDir
|
|
214
219
|
}, supportedScopes, supportedPackages);
|
|
215
220
|
case 20:
|
|
216
221
|
_yield$getEventsFromH = _context3.sent;
|
|
@@ -66,7 +66,7 @@ export function createUpgradeEvent(name, version, previousVersion, date) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
return _objectSpread({
|
|
69
|
-
cliVersion: "1.
|
|
69
|
+
cliVersion: "1.6.1",
|
|
70
70
|
dependencyName: name,
|
|
71
71
|
versionString: eventVersion,
|
|
72
72
|
major: parsedVersion ? "".concat(parsedVersion.major) : null,
|
package/dist/esm/util/yarn.js
CHANGED
|
@@ -10,65 +10,64 @@ export function getWorkspacePackageJsonPaths(_x, _x2) {
|
|
|
10
10
|
return _getWorkspacePackageJsonPaths.apply(this, arguments);
|
|
11
11
|
}
|
|
12
12
|
function _getWorkspacePackageJsonPaths() {
|
|
13
|
-
_getWorkspacePackageJsonPaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(hash,
|
|
14
|
-
var file, errorMessage, rootPackageJsonFile, workspaces, workspacePackages;
|
|
13
|
+
_getWorkspacePackageJsonPaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(hash, subWorkDir) {
|
|
14
|
+
var file, rootPackageJson, errorMessage, rootPackageJsonFile, workspaces, workspacePackages;
|
|
15
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
16
|
while (1) switch (_context.prev = _context.next) {
|
|
17
17
|
case 0:
|
|
18
|
-
|
|
19
|
-
_context.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
case 3:
|
|
18
|
+
rootPackageJson = "".concat(subWorkDir ? "".concat(subWorkDir, "/") : '', "package.json");
|
|
19
|
+
_context.prev = 1;
|
|
20
|
+
_context.next = 4;
|
|
21
|
+
return git.showFile(hash, rootPackageJson);
|
|
22
|
+
case 4:
|
|
24
23
|
file = _context.sent;
|
|
25
|
-
_context.next =
|
|
24
|
+
_context.next = 13;
|
|
26
25
|
break;
|
|
27
|
-
case
|
|
28
|
-
_context.prev =
|
|
29
|
-
_context.t0 = _context["catch"](
|
|
30
|
-
errorMessage = "File by hash \"".concat(hash, "\" and path \"").concat(
|
|
26
|
+
case 7:
|
|
27
|
+
_context.prev = 7;
|
|
28
|
+
_context.t0 = _context["catch"](1);
|
|
29
|
+
errorMessage = "File by hash \"".concat(hash, "\" and path \"").concat(rootPackageJson, "\" does not exist");
|
|
31
30
|
debug(errorMessage, {
|
|
32
31
|
error: _context.t0
|
|
33
32
|
});
|
|
34
33
|
console.error(errorMessage, _context.t0);
|
|
35
34
|
return _context.abrupt("return", new Set([]));
|
|
36
|
-
case
|
|
37
|
-
_context.prev =
|
|
35
|
+
case 13:
|
|
36
|
+
_context.prev = 13;
|
|
38
37
|
rootPackageJsonFile = JSON.parse(file);
|
|
39
|
-
_context.next =
|
|
38
|
+
_context.next = 21;
|
|
40
39
|
break;
|
|
41
|
-
case
|
|
42
|
-
_context.prev =
|
|
43
|
-
_context.t1 = _context["catch"](
|
|
40
|
+
case 17:
|
|
41
|
+
_context.prev = 17;
|
|
42
|
+
_context.t1 = _context["catch"](13);
|
|
44
43
|
console.error("Error parsing ".concat(file, "@").concat(hash, ": ").concat(_context.t1));
|
|
45
44
|
return _context.abrupt("return", null);
|
|
46
|
-
case
|
|
45
|
+
case 21:
|
|
47
46
|
workspaces = rootPackageJsonFile.workspaces;
|
|
48
47
|
if (workspaces) {
|
|
49
|
-
_context.next =
|
|
48
|
+
_context.next = 24;
|
|
50
49
|
break;
|
|
51
50
|
}
|
|
52
|
-
return _context.abrupt("return", new Set([
|
|
53
|
-
case
|
|
51
|
+
return _context.abrupt("return", new Set([rootPackageJson]));
|
|
52
|
+
case 24:
|
|
54
53
|
// There are actually two formats for workspaces and they are poorly documented
|
|
55
54
|
workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
|
|
56
|
-
return _context.abrupt("return", new Set([
|
|
55
|
+
return _context.abrupt("return", new Set([rootPackageJson].concat(_toConsumableArray(workspacePackages.map(function (glob) {
|
|
57
56
|
return path.join(glob, 'package.json');
|
|
58
57
|
})))));
|
|
59
|
-
case
|
|
58
|
+
case 26:
|
|
60
59
|
case "end":
|
|
61
60
|
return _context.stop();
|
|
62
61
|
}
|
|
63
|
-
}, _callee, null, [[
|
|
62
|
+
}, _callee, null, [[1, 7], [13, 17]]);
|
|
64
63
|
}));
|
|
65
64
|
return _getWorkspacePackageJsonPaths.apply(this, arguments);
|
|
66
65
|
}
|
|
67
|
-
export function getWorkspacePaths(_x3, _x4
|
|
66
|
+
export function getWorkspacePaths(_x3, _x4) {
|
|
68
67
|
return _getWorkspacePaths.apply(this, arguments);
|
|
69
68
|
}
|
|
70
69
|
function _getWorkspacePaths() {
|
|
71
|
-
_getWorkspacePaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ref, workspaceGlobs
|
|
70
|
+
_getWorkspacePaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ref, workspaceGlobs) {
|
|
72
71
|
var workspacePackageJsons, matchedWorkspaces;
|
|
73
72
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
74
73
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -80,9 +79,7 @@ function _getWorkspacePaths() {
|
|
|
80
79
|
return _context2.abrupt("return", []);
|
|
81
80
|
case 2:
|
|
82
81
|
_context2.next = 4;
|
|
83
|
-
return git.getFiles(ref, '**/package.json'
|
|
84
|
-
cwd: cwd
|
|
85
|
-
});
|
|
82
|
+
return git.getFiles(ref, '**/package.json');
|
|
86
83
|
case 4:
|
|
87
84
|
workspacePackageJsons = _context2.sent;
|
|
88
85
|
matchedWorkspaces = micromatch(workspacePackageJsons, _toConsumableArray(workspaceGlobs));
|
|
@@ -90,7 +87,7 @@ function _getWorkspacePaths() {
|
|
|
90
87
|
_context2.next = 8;
|
|
91
88
|
break;
|
|
92
89
|
}
|
|
93
|
-
throw new Error("Could not find any workspace or package.json under \"".concat(cwd, "\" for \"").concat(ref, "\" tag"));
|
|
90
|
+
throw new Error("Could not find any workspace or package.json under \"".concat(process.cwd(), "\" for \"").concat(ref, "\" tag"));
|
|
94
91
|
case 8:
|
|
95
92
|
return _context2.abrupt("return", matchedWorkspaces);
|
|
96
93
|
case 9:
|
|
@@ -5,7 +5,12 @@ import type { DefaultLogFields, ListLogLine } from 'simple-git';
|
|
|
5
5
|
* Stores the state of atlaskit dependencies in a repository
|
|
6
6
|
*/
|
|
7
7
|
export declare class DependencyStore {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* We may want to work not in root, but in specific directory
|
|
10
|
+
* The reason is - some repositories have their package.json not in root
|
|
11
|
+
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
12
|
+
*/
|
|
13
|
+
private subWorkDir?;
|
|
9
14
|
/** Mapping of dependency names to arrays of unique dependency type + versions */
|
|
10
15
|
private dependencies;
|
|
11
16
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
@@ -15,7 +20,11 @@ export declare class DependencyStore {
|
|
|
15
20
|
private initialised;
|
|
16
21
|
private supportedScopes;
|
|
17
22
|
private supportedPackages;
|
|
18
|
-
constructor(
|
|
23
|
+
constructor({ subWorkDir, supportedScopes, supportedPackages, }: {
|
|
24
|
+
subWorkDir?: string;
|
|
25
|
+
supportedScopes: string[];
|
|
26
|
+
supportedPackages: string[];
|
|
27
|
+
});
|
|
19
28
|
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
20
29
|
initialise(gitRef?: string): Promise<DependencyMap>;
|
|
21
30
|
/** Updates the repo dependency store based on the changes in `logItem`.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getWorkspacePackageJsonPaths(hash: string,
|
|
2
|
-
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string
|
|
1
|
+
export declare function getWorkspacePackageJsonPaths(hash: string, subWorkDir?: string): Promise<Set<string> | null>;
|
|
2
|
+
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string>): Promise<string[]>;
|
|
@@ -5,7 +5,12 @@ import type { DefaultLogFields, ListLogLine } from 'simple-git';
|
|
|
5
5
|
* Stores the state of atlaskit dependencies in a repository
|
|
6
6
|
*/
|
|
7
7
|
export declare class DependencyStore {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* We may want to work not in root, but in specific directory
|
|
10
|
+
* The reason is - some repositories have their package.json not in root
|
|
11
|
+
* For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
|
|
12
|
+
*/
|
|
13
|
+
private subWorkDir?;
|
|
9
14
|
/** Mapping of dependency names to arrays of unique dependency type + versions */
|
|
10
15
|
private dependencies;
|
|
11
16
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
@@ -15,7 +20,11 @@ export declare class DependencyStore {
|
|
|
15
20
|
private initialised;
|
|
16
21
|
private supportedScopes;
|
|
17
22
|
private supportedPackages;
|
|
18
|
-
constructor(
|
|
23
|
+
constructor({ subWorkDir, supportedScopes, supportedPackages, }: {
|
|
24
|
+
subWorkDir?: string;
|
|
25
|
+
supportedScopes: string[];
|
|
26
|
+
supportedPackages: string[];
|
|
27
|
+
});
|
|
19
28
|
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
20
29
|
initialise(gitRef?: string): Promise<DependencyMap>;
|
|
21
30
|
/** Updates the repo dependency store based on the changes in `logItem`.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function getWorkspacePackageJsonPaths(hash: string,
|
|
2
|
-
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string
|
|
1
|
+
export declare function getWorkspacePackageJsonPaths(hash: string, subWorkDir?: string): Promise<Set<string> | null>;
|
|
2
|
+
export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string>): Promise<string[]>;
|
package/package.json
CHANGED
package/report.api.md
CHANGED