@salesforce/plugin-release-management 4.1.27 → 4.1.29-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cli/install/jit/test.d.ts +6 -0
- package/lib/commands/cli/install/jit/test.js +26 -0
- package/lib/commands/cli/install/jit/test.js.map +1 -0
- package/lib/commands/cli/tarballs/smoke.js +8 -70
- package/lib/commands/cli/tarballs/smoke.js.map +1 -1
- package/lib/jit.d.ts +7 -0
- package/lib/jit.js +127 -0
- package/lib/jit.js.map +1 -0
- package/messages/cli.install.jit.test.md +7 -0
- package/npm-shrinkwrap.json +358 -1318
- package/oclif.manifest.json +23 -1
- package/package.json +6 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
11
|
+
const core_1 = require("@salesforce/core");
|
|
12
|
+
const jit_1 = require("../../../../jit");
|
|
13
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
14
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-release-management', 'cli.install.jit.test');
|
|
15
|
+
class Test extends sf_plugins_core_1.SfCommand {
|
|
16
|
+
async run() {
|
|
17
|
+
await (0, jit_1.testJITInstall)({
|
|
18
|
+
jsonEnabled: this.jsonEnabled(),
|
|
19
|
+
executable: process.platform === 'win32' ? (0, path_1.join)('bin', 'run.cmd') : (0, path_1.join)('bin', 'run'),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
Test.summary = messages.getMessage('summary');
|
|
24
|
+
Test.examples = messages.getMessages('examples');
|
|
25
|
+
exports.default = Test;
|
|
26
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../../../src/commands/cli/install/jit/test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,+BAA4B;AAC5B,iEAAwD;AACxD,2CAA4C;AAC5C,yCAAiD;AAEjD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,uCAAuC,EAAE,sBAAsB,CAAC,CAAC;AAExG,MAAqB,IAAK,SAAQ,2BAAe;IAIxC,KAAK,CAAC,GAAG;QACd,MAAM,IAAA,oBAAc,EAAC;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,UAAU,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,KAAK,EAAE,KAAK,CAAC;SACvF,CAAC,CAAC;IACL,CAAC;;AARsB,YAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,aAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;kBAFhD,IAAI"}
|
|
@@ -17,17 +17,14 @@ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
|
17
17
|
const core_1 = require("@salesforce/core");
|
|
18
18
|
const kit_1 = require("@salesforce/kit");
|
|
19
19
|
const types_1 = require("../../../types");
|
|
20
|
+
const jit_1 = require("../../../jit");
|
|
20
21
|
const exec = (0, node_util_1.promisify)(child_process_1.exec);
|
|
21
22
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
22
23
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-release-management', 'cli.tarballs.smoke');
|
|
23
24
|
class SmokeTest extends sf_plugins_core_1.SfCommand {
|
|
24
25
|
async run() {
|
|
25
26
|
this.flags = (await this.parse(SmokeTest)).flags;
|
|
26
|
-
|
|
27
|
-
if (this.flags.cli === types_1.CLI.SFDX) {
|
|
28
|
-
executables.push(path.join('tmp', this.flags.cli, 'bin', types_1.CLI.SF));
|
|
29
|
-
}
|
|
30
|
-
await Promise.all(executables.map((executable) => this.smokeTest(executable)));
|
|
27
|
+
await this.smokeTest(path.join('tmp', this.flags.cli, 'bin', this.flags.cli));
|
|
31
28
|
}
|
|
32
29
|
async smokeTest(executable) {
|
|
33
30
|
await Promise.all([
|
|
@@ -36,74 +33,15 @@ class SmokeTest extends sf_plugins_core_1.SfCommand {
|
|
|
36
33
|
this.execute(executable, 'plugins --core'),
|
|
37
34
|
this.testInstall(executable, '@salesforce/plugin-alias', 'latest'),
|
|
38
35
|
]);
|
|
39
|
-
|
|
40
|
-
if (this.flags.cli === types_1.CLI.SFDX && !executable.endsWith('sf')) {
|
|
41
|
-
await this.testJITInstall(executable);
|
|
42
|
-
}
|
|
36
|
+
await this.testJITInstall(executable);
|
|
43
37
|
await this.initializeAllCommands(executable);
|
|
44
38
|
}
|
|
45
39
|
async testJITInstall(executable) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
const manifestData = await fs.promises.readFile(path.join('tmp', this.flags.cli, 'oclif.manifest.json'), 'utf8');
|
|
53
|
-
const manifest = (0, kit_1.parseJson)(manifestData);
|
|
54
|
-
const commands = Object.values(manifest.commands);
|
|
55
|
-
let failed = false;
|
|
56
|
-
const help = async (command) => {
|
|
57
|
-
try {
|
|
58
|
-
await exec(`${executable} ${command} --help`);
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
// We have to test these serially in order to avoid issues when running plugin installs concurrently.
|
|
66
|
-
for (const plugin of jitPlugins) {
|
|
67
|
-
try {
|
|
68
|
-
this.log(`Testing JIT install for ${plugin}`);
|
|
69
|
-
const firstCommand = commands.find((c) => c.pluginName === plugin);
|
|
70
|
-
if (!firstCommand) {
|
|
71
|
-
throw new core_1.SfError(`Unable to find command for ${plugin}`);
|
|
72
|
-
}
|
|
73
|
-
// Test that --help works on JIT commands
|
|
74
|
-
const helpResult = await help(firstCommand.id);
|
|
75
|
-
this.log(`${executable} ${firstCommand.id} --help ${helpResult ? chalk.green('PASSED') : chalk.red('FAILED')}`);
|
|
76
|
-
this.log(`${executable} ${firstCommand.id}`);
|
|
77
|
-
// Test that executing the command will trigger JIT install
|
|
78
|
-
// This will likely always fail because we're not providing all the required flags or it depends on some other setup.
|
|
79
|
-
// However, this is okay because all we need to verify is that running the command will trigger the JIT install
|
|
80
|
-
const { stdout, stderr } = await exec(`${executable} ${firstCommand.id}`, { maxBuffer: 1024 * 1024 * 100 });
|
|
81
|
-
this.log(stdout);
|
|
82
|
-
this.log(stderr);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
const err = e;
|
|
86
|
-
// @ts-expect-error ExecException type doesn't have a stdout or stderr property
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
88
|
-
this.log(err.stdout);
|
|
89
|
-
// @ts-expect-error ExecException type doesn't have a stdout or stderr property
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
91
|
-
this.log(err.stderr);
|
|
92
|
-
}
|
|
93
|
-
finally {
|
|
94
|
-
const result = await this.verifyInstall(plugin, executable, true);
|
|
95
|
-
if (result) {
|
|
96
|
-
this.log(`✅ ${chalk.green(`Verified installation of ${plugin}\n`)}`);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
failed = true;
|
|
100
|
-
this.log(`❌ ${chalk.red(`Failed installation of ${plugin}\n`)}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (failed) {
|
|
105
|
-
throw new core_1.SfError('Failed JIT installation');
|
|
106
|
-
}
|
|
40
|
+
await (0, jit_1.testJITInstall)({
|
|
41
|
+
jsonEnabled: this.jsonEnabled(),
|
|
42
|
+
executable,
|
|
43
|
+
manifestPath: path.join('tmp', this.flags.cli, 'oclif.manifest.json'),
|
|
44
|
+
});
|
|
107
45
|
}
|
|
108
46
|
async testInstall(executable, plugin, tag) {
|
|
109
47
|
await this.execute(executable, `plugins:install ${plugin}${tag ? `@${tag}` : ''}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smoke.js","sourceRoot":"","sources":["../../../../src/commands/cli/tarballs/smoke.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,qCAAqC;AACrC,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"smoke.js","sourceRoot":"","sources":["../../../../src/commands/cli/tarballs/smoke.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,qCAAqC;AACrC,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,iDAAiD;AACjD,yCAAsC;AACtC,+BAA+B;AAC/B,iEAA+D;AAC/D,2CAAqD;AACrD,yCAA2E;AAE3E,0CAAqC;AAErC,sCAA8C;AAE9C,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,oBAAQ,CAAC,CAAC;AAEjC,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,uCAAuC,EAAE,oBAAoB,CAAC,CAAC;AAEtG,MAAqB,SAAU,SAAQ,2BAAe;IAoB7C,KAAK,CAAC,GAAG;QACd,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;QACjD,MAAM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EAAE;gBACX,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;aAClB;YACD,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,GAAG,GAAG,CAAU,CAAC;YACvB,MAAM,IAAI,cAAO,CAAC,WAAW,OAAO,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;SAC1F;IACH,CAAC;;AArHsB,iBAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC7C,qBAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAEjD,kBAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAC5C,eAAK,GAAG;IAC7B,GAAG,EAAE,uBAAK,CAAC,MAAM,CAAM;QACrB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,WAAG,CAAC;KAC5B,CAAC,CAAC;QACD,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QACvC,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,IAAI;KACf,CAAC;IACF,OAAO,EAAE,uBAAK,CAAC,OAAO,CAAC;QACrB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC;KAC5C,CAAC;CACH,CAAC;kBAhBiB,SAAS"}
|
package/lib/jit.d.ts
ADDED
package/lib/jit.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testJITInstall = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
/* eslint-disable no-await-in-loop */
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const os = require("os");
|
|
14
|
+
const util_1 = require("util");
|
|
15
|
+
const child_process_1 = require("child_process");
|
|
16
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
17
|
+
const chalk = require("chalk");
|
|
18
|
+
const core_1 = require("@salesforce/core");
|
|
19
|
+
const kit_1 = require("@salesforce/kit");
|
|
20
|
+
const stripAnsi = require("strip-ansi");
|
|
21
|
+
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
22
|
+
async function testJITInstall(options) {
|
|
23
|
+
const { jsonEnabled, executable } = options;
|
|
24
|
+
const ux = new sf_plugins_core_1.Ux({ jsonEnabled });
|
|
25
|
+
const tmpDir = path.join(os.tmpdir(), 'sf-jit-test');
|
|
26
|
+
// Clear tmp dir before test to ensure that we're starting from a clean slate
|
|
27
|
+
await fs.promises.rm(tmpDir, { recursive: true, force: true });
|
|
28
|
+
await fs.promises.mkdir(tmpDir, { recursive: true });
|
|
29
|
+
const dataDir = path.join(tmpDir, 'data');
|
|
30
|
+
const cacheDir = path.join(tmpDir, 'cache');
|
|
31
|
+
const configDir = path.join(tmpDir, 'config');
|
|
32
|
+
process.env.SF_DATA_DIR = dataDir;
|
|
33
|
+
process.env.SF_CACHE_DIR = cacheDir;
|
|
34
|
+
process.env.SF_CONFIG_DIR = configDir;
|
|
35
|
+
await fs.promises.mkdir(dataDir, { recursive: true });
|
|
36
|
+
await fs.promises.mkdir(cacheDir, { recursive: true });
|
|
37
|
+
await fs.promises.mkdir(configDir, { recursive: true });
|
|
38
|
+
ux.styledHeader('Testing JIT installation');
|
|
39
|
+
ux.log(`SF_DATA_DIR: ${dataDir}`);
|
|
40
|
+
ux.log(`SF_CACHE_DIR: ${cacheDir}`);
|
|
41
|
+
ux.log(`SF_CONFIG_DIR: ${configDir}`);
|
|
42
|
+
const fileData = await fs.promises.readFile('package.json', 'utf8');
|
|
43
|
+
const packageJson = (0, kit_1.parseJson)(fileData);
|
|
44
|
+
const jitPlugins = Object.keys(packageJson.oclif?.jitPlugins ?? {});
|
|
45
|
+
if (jitPlugins.length === 0)
|
|
46
|
+
return;
|
|
47
|
+
let manifestData;
|
|
48
|
+
try {
|
|
49
|
+
manifestData = options.manifestPath
|
|
50
|
+
? await fs.promises.readFile(options.manifestPath, 'utf8')
|
|
51
|
+
: await fs.promises.readFile('oclif.manifest.json', 'utf8');
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
ux.log('No oclif.manifest.json found. Generating one now.');
|
|
55
|
+
await exec('yarn oclif manifest');
|
|
56
|
+
manifestData = await fs.promises.readFile('oclif.manifest.json', 'utf8');
|
|
57
|
+
}
|
|
58
|
+
const manifest = (0, kit_1.parseJson)(manifestData);
|
|
59
|
+
const commands = Object.values(manifest.commands);
|
|
60
|
+
const help = async (command) => {
|
|
61
|
+
try {
|
|
62
|
+
await exec(`${executable} ${command} --help`);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const verifyInstall = async (plugin) => {
|
|
70
|
+
const userPjsonRaw = await fs.promises.readFile(path.join(dataDir, 'package.json'), 'utf-8');
|
|
71
|
+
const userPjson = (0, kit_1.parseJson)(userPjsonRaw);
|
|
72
|
+
return Boolean(userPjson.dependencies?.[plugin]);
|
|
73
|
+
};
|
|
74
|
+
const passedInstalls = [];
|
|
75
|
+
const failedInstalls = [];
|
|
76
|
+
// We have to test these serially in order to avoid issues when running plugin installs concurrently.
|
|
77
|
+
for (const plugin of jitPlugins) {
|
|
78
|
+
try {
|
|
79
|
+
ux.log(`Testing JIT install for ${plugin}`);
|
|
80
|
+
const firstCommand = commands.find((c) => c.pluginName === plugin);
|
|
81
|
+
if (!firstCommand) {
|
|
82
|
+
throw new core_1.SfError(`Unable to find command for ${plugin}`);
|
|
83
|
+
}
|
|
84
|
+
// Test that --help works on JIT commands
|
|
85
|
+
const helpResult = await help(firstCommand.id);
|
|
86
|
+
ux.log(`${executable} ${firstCommand.id} --help ${helpResult ? chalk.green('PASSED') : chalk.red('FAILED')}`);
|
|
87
|
+
ux.log(`${executable} ${firstCommand.id}`);
|
|
88
|
+
// Test that executing the command will trigger JIT install
|
|
89
|
+
// This will likely always fail because we're not providing all the required flags or it depends on some other setup.
|
|
90
|
+
// However, this is okay because all we need to verify is that running the command will trigger the JIT install
|
|
91
|
+
const { stdout, stderr } = await exec(`${executable} ${firstCommand.id}`);
|
|
92
|
+
ux.log(stripAnsi(stdout));
|
|
93
|
+
ux.log(stripAnsi(stderr));
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
const err = e;
|
|
97
|
+
// @ts-expect-error ExecException type doesn't have a stdout or stderr property
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
99
|
+
ux.log(stripAnsi(err.stdout));
|
|
100
|
+
// @ts-expect-error ExecException type doesn't have a stdout or stderr property
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
102
|
+
ux.log(stripAnsi(err.stderr));
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
const result = await verifyInstall(plugin);
|
|
106
|
+
if (result) {
|
|
107
|
+
ux.log(`✅ ${chalk.green(`Verified installation of ${plugin}\n`)}`);
|
|
108
|
+
passedInstalls.push(plugin);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
ux.log(`❌ ${chalk.red(`Failed installation of ${plugin}\n`)}`);
|
|
112
|
+
failedInstalls.push(plugin);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
ux.styledHeader('JIT Installation Results');
|
|
117
|
+
ux.log(`Passed (${passedInstalls.length})`);
|
|
118
|
+
passedInstalls.forEach((msg) => ux.log(`• ${msg}`));
|
|
119
|
+
if (failedInstalls.length) {
|
|
120
|
+
ux.log();
|
|
121
|
+
ux.log(`Failed (${failedInstalls.length})`);
|
|
122
|
+
failedInstalls.forEach((msg) => ux.log(`• ${msg}`));
|
|
123
|
+
throw new core_1.SfError('Failed JIT installation');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.testJITInstall = testJITInstall;
|
|
127
|
+
//# sourceMappingURL=jit.js.map
|
package/lib/jit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit.js","sourceRoot":"","sources":["../src/jit.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,qCAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAC7B,yBAAyB;AACzB,+BAAiC;AACjC,iDAAgE;AAChE,iEAAiD;AACjD,+BAA+B;AAC/B,2CAA2C;AAC3C,yCAA4C;AAE5C,wCAAyC;AAGzC,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,oBAAQ,CAAC,CAAC;AAQ1B,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,EAAE,GAAG,IAAI,oBAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAEnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;IACrD,6EAA6E;IAC7E,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC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