@atlaspack/reporter-conditional-manifest 2.14.1 → 2.14.2
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
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaspack/reporter-conditional-manifest
|
|
2
2
|
|
|
3
|
+
## 2.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#494](https://github.com/atlassian-labs/atlaspack/pull/494) [`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062) Thanks [@JakeLane](https://github.com/JakeLane)! - When conditionalBundlingReporterDuplicateFix is enabled, avoid duplicated writes to the descriptor and logging
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062), [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39), [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f)]:
|
|
10
|
+
- @atlaspack/feature-flags@2.14.2
|
|
11
|
+
- @atlaspack/plugin@2.14.2
|
|
12
|
+
|
|
3
13
|
## 2.14.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.manifestHashes = exports.default = void 0;
|
|
7
|
+
exports.report = report;
|
|
8
|
+
exports.updateManifest = void 0;
|
|
7
9
|
function _path() {
|
|
8
10
|
const data = require("path");
|
|
9
11
|
_path = function () {
|
|
@@ -11,6 +13,13 @@ function _path() {
|
|
|
11
13
|
};
|
|
12
14
|
return data;
|
|
13
15
|
}
|
|
16
|
+
function _crypto() {
|
|
17
|
+
const data = _interopRequireDefault(require("crypto"));
|
|
18
|
+
_crypto = function () {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
14
23
|
function _plugin() {
|
|
15
24
|
const data = require("@atlaspack/plugin");
|
|
16
25
|
_plugin = function () {
|
|
@@ -19,6 +28,29 @@ function _plugin() {
|
|
|
19
28
|
return data;
|
|
20
29
|
}
|
|
21
30
|
var _Config = require("./Config");
|
|
31
|
+
function _featureFlags() {
|
|
32
|
+
const data = require("@atlaspack/feature-flags");
|
|
33
|
+
_featureFlags = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
+
const manifestHashes = exports.manifestHashes = new Map();
|
|
40
|
+
const updateManifest = async (outputFS, logger, conditionalManifestFilename, conditionalManifest) => {
|
|
41
|
+
const hash = _crypto().default.createHash('sha1').update(conditionalManifest).digest('hex');
|
|
42
|
+
if (manifestHashes.get(conditionalManifestFilename) !== hash) {
|
|
43
|
+
manifestHashes.set(conditionalManifestFilename, hash);
|
|
44
|
+
await outputFS.mkdirp((0, _path().dirname)(conditionalManifestFilename));
|
|
45
|
+
await outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
|
|
46
|
+
mode: 0o666
|
|
47
|
+
});
|
|
48
|
+
logger.info({
|
|
49
|
+
message: `Wrote conditional manifest to ${conditionalManifestFilename}`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.updateManifest = updateManifest;
|
|
22
54
|
async function report({
|
|
23
55
|
event,
|
|
24
56
|
options,
|
|
@@ -52,13 +84,17 @@ async function report({
|
|
|
52
84
|
const conditionalManifest = JSON.stringify(
|
|
53
85
|
// If there's no content, send an empty manifest so we can still map from it safely
|
|
54
86
|
manifest[target.name] ?? {}, null, 2);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterDuplicateFix')) {
|
|
88
|
+
await updateManifest(options.outputFS, logger, conditionalManifestFilename, conditionalManifest);
|
|
89
|
+
} else {
|
|
90
|
+
await options.outputFS.mkdirp((0, _path().dirname)(conditionalManifestFilename));
|
|
91
|
+
await options.outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
|
|
92
|
+
mode: 0o666
|
|
93
|
+
});
|
|
94
|
+
logger.info({
|
|
95
|
+
message: 'Wrote conditional manifest to ' + conditionalManifestFilename
|
|
96
|
+
});
|
|
97
|
+
}
|
|
62
98
|
}
|
|
63
99
|
}
|
|
64
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/reporter-conditional-manifest",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"node": ">= 16.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atlaspack/plugin": "2.14.
|
|
18
|
+
"@atlaspack/plugin": "2.14.2",
|
|
19
|
+
"@atlaspack/feature-flags": "2.14.2",
|
|
19
20
|
"nullthrows": "^1.1.1"
|
|
20
21
|
},
|
|
21
22
|
"type": "commonjs"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
import {relative, join, dirname} from 'path';
|
|
3
|
+
import crypto from 'crypto';
|
|
3
4
|
import {Reporter} from '@atlaspack/plugin';
|
|
4
5
|
import type {
|
|
5
6
|
Async,
|
|
@@ -7,10 +8,40 @@ import type {
|
|
|
7
8
|
PluginOptions,
|
|
8
9
|
PluginTracer,
|
|
9
10
|
ReporterEvent,
|
|
11
|
+
FileSystem,
|
|
12
|
+
FilePath,
|
|
10
13
|
} from '@atlaspack/types-internal';
|
|
11
14
|
import {getConfig} from './Config';
|
|
15
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
export const manifestHashes: Map<FilePath, string> = new Map();
|
|
18
|
+
|
|
19
|
+
export const updateManifest = async (
|
|
20
|
+
outputFS: FileSystem,
|
|
21
|
+
logger: PluginLogger,
|
|
22
|
+
conditionalManifestFilename: FilePath,
|
|
23
|
+
conditionalManifest: string,
|
|
24
|
+
) => {
|
|
25
|
+
const hash = crypto
|
|
26
|
+
.createHash('sha1')
|
|
27
|
+
.update(conditionalManifest)
|
|
28
|
+
.digest('hex');
|
|
29
|
+
|
|
30
|
+
if (manifestHashes.get(conditionalManifestFilename) !== hash) {
|
|
31
|
+
manifestHashes.set(conditionalManifestFilename, hash);
|
|
32
|
+
|
|
33
|
+
await outputFS.mkdirp(dirname(conditionalManifestFilename));
|
|
34
|
+
await outputFS.writeFile(conditionalManifestFilename, conditionalManifest, {
|
|
35
|
+
mode: 0o666,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
logger.info({
|
|
39
|
+
message: `Wrote conditional manifest to ${conditionalManifestFilename}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export async function report({
|
|
14
45
|
event,
|
|
15
46
|
options,
|
|
16
47
|
logger,
|
|
@@ -59,17 +90,26 @@ async function report({
|
|
|
59
90
|
2,
|
|
60
91
|
);
|
|
61
92
|
|
|
62
|
-
|
|
93
|
+
if (getFeatureFlag('conditionalBundlingReporterDuplicateFix')) {
|
|
94
|
+
await updateManifest(
|
|
95
|
+
options.outputFS,
|
|
96
|
+
logger,
|
|
97
|
+
conditionalManifestFilename,
|
|
98
|
+
conditionalManifest,
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
await options.outputFS.mkdirp(dirname(conditionalManifestFilename));
|
|
102
|
+
await options.outputFS.writeFile(
|
|
103
|
+
conditionalManifestFilename,
|
|
104
|
+
conditionalManifest,
|
|
105
|
+
{mode: 0o666},
|
|
106
|
+
);
|
|
63
107
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
logger.info({
|
|
71
|
-
message: 'Wrote conditional manifest to ' + conditionalManifestFilename,
|
|
72
|
-
});
|
|
108
|
+
logger.info({
|
|
109
|
+
message:
|
|
110
|
+
'Wrote conditional manifest to ' + conditionalManifestFilename,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
73
113
|
}
|
|
74
114
|
}
|
|
75
115
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
import {
|
|
3
|
+
manifestHashes,
|
|
4
|
+
updateManifest,
|
|
5
|
+
} from '../src/ConditionalManifestReporter';
|
|
6
|
+
import sinon from 'sinon';
|
|
7
|
+
import assert from 'assert';
|
|
8
|
+
|
|
9
|
+
let createMockOverlayFS = () => ({
|
|
10
|
+
// Mock filesystem methods
|
|
11
|
+
writeFile: sinon.stub(),
|
|
12
|
+
readFile: sinon.stub(),
|
|
13
|
+
exists: sinon.stub(),
|
|
14
|
+
chdir: sinon.stub(),
|
|
15
|
+
copyFile: sinon.stub(),
|
|
16
|
+
createReadStream: sinon.stub(),
|
|
17
|
+
createWriteStream: sinon.stub(),
|
|
18
|
+
cwd: sinon.stub(),
|
|
19
|
+
existsSync: sinon.stub(),
|
|
20
|
+
findAncestorFile: sinon.stub(),
|
|
21
|
+
findFirstFile: sinon.stub(),
|
|
22
|
+
findNodeModule: sinon.stub(),
|
|
23
|
+
getEventsSince: sinon.stub(),
|
|
24
|
+
mkdirp: sinon.stub(),
|
|
25
|
+
ncp: sinon.stub(),
|
|
26
|
+
readFileSync: sinon.stub(),
|
|
27
|
+
readdir: sinon.stub(),
|
|
28
|
+
readdirSync: sinon.stub(),
|
|
29
|
+
realpath: sinon.stub(),
|
|
30
|
+
realpathSync: sinon.stub(),
|
|
31
|
+
rimraf: sinon.stub(),
|
|
32
|
+
stat: sinon.stub(),
|
|
33
|
+
statSync: sinon.stub(),
|
|
34
|
+
symlink: sinon.stub(),
|
|
35
|
+
unlink: sinon.stub(),
|
|
36
|
+
watch: sinon.stub(),
|
|
37
|
+
writeSnapshot: sinon.stub(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let createMockLogger = () => ({
|
|
41
|
+
// Mock logger methods
|
|
42
|
+
warn: sinon.stub(),
|
|
43
|
+
info: sinon.stub(),
|
|
44
|
+
verbose: sinon.stub(),
|
|
45
|
+
error: sinon.stub(),
|
|
46
|
+
log: sinon.stub(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('ConditionalManifestReporter', function () {
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
manifestHashes.clear();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should write the manifest to file', async function () {
|
|
55
|
+
let logger = createMockLogger();
|
|
56
|
+
let overlayFS = createMockOverlayFS();
|
|
57
|
+
|
|
58
|
+
const conditionalManifestFilename =
|
|
59
|
+
'/project-root/dist/conditional-manifest.json';
|
|
60
|
+
const conditionalManifest = JSON.stringify({test: 'manifest'});
|
|
61
|
+
|
|
62
|
+
await updateManifest(
|
|
63
|
+
overlayFS,
|
|
64
|
+
logger,
|
|
65
|
+
conditionalManifestFilename,
|
|
66
|
+
conditionalManifest,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Verify that writeFile was called with the correct arguments
|
|
70
|
+
assert(
|
|
71
|
+
overlayFS.writeFile.calledWith(
|
|
72
|
+
conditionalManifestFilename,
|
|
73
|
+
conditionalManifest,
|
|
74
|
+
{mode: 0o666},
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Verify that logger.info was called with the correct message
|
|
79
|
+
assert(
|
|
80
|
+
logger.info.calledWith({
|
|
81
|
+
message: `Wrote conditional manifest to ${conditionalManifestFilename}`,
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should not write the manifest if it has not changed', async function () {
|
|
87
|
+
let logger = createMockLogger();
|
|
88
|
+
let overlayFS = createMockOverlayFS();
|
|
89
|
+
|
|
90
|
+
let conditionalManifestFilename =
|
|
91
|
+
'/project-root/dist/conditional-manifest.json';
|
|
92
|
+
let conditionalManifest = JSON.stringify({test: 'manifest'});
|
|
93
|
+
|
|
94
|
+
await updateManifest(
|
|
95
|
+
overlayFS,
|
|
96
|
+
logger,
|
|
97
|
+
conditionalManifestFilename,
|
|
98
|
+
conditionalManifest,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
await updateManifest(
|
|
102
|
+
overlayFS,
|
|
103
|
+
logger,
|
|
104
|
+
conditionalManifestFilename,
|
|
105
|
+
conditionalManifest,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Verify that writeFile was called once
|
|
109
|
+
assert(overlayFS.writeFile.calledOnce);
|
|
110
|
+
|
|
111
|
+
// Verify that logger.info was called with the correct message
|
|
112
|
+
assert(logger.info.calledOnce);
|
|
113
|
+
});
|
|
114
|
+
});
|