@react-native-oh/react-native-harmony-cli 0.0.25 → 0.0.26
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/.prettierrc +6 -6
- package/jest.config.js +5 -5
- package/package.json +57 -56
- package/react-native.config.js +10 -10
- package/src/assetResolver.ts +21 -44
- package/src/codegen/core/CodeGenerator.ts +9 -0
- package/src/codegen/core/CodegenError.ts +3 -3
- package/src/codegen/core/EventUtils.ts +18 -18
- package/src/codegen/core/TypeAnnotationToTS.test.ts +75 -75
- package/src/codegen/core/TypeAnnotationToTS.ts +188 -188
- package/src/codegen/core/UberSchema.ts +142 -99
- package/src/codegen/core/index.ts +5 -5
- package/src/codegen/generators/{ComponentCodeGenerator.ts → ComponentCodeGeneratorArkTS.ts} +112 -98
- package/src/codegen/generators/ComponentCodeGeneratorCAPI.ts +114 -0
- package/src/codegen/generators/GlueCodeGenerator.ts +109 -0
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +115 -95
- package/src/codegen/generators/UberGeneratorV1.ts +64 -0
- package/src/codegen/generators/UberGeneratorV2.ts +91 -0
- package/src/codegen/generators/index.ts +6 -3
- package/src/codegen/index.ts +2 -2
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +116 -0
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +55 -49
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +93 -85
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +210 -202
- package/src/codegen/templates/GeneratedPackageHTemplate.ts +107 -0
- package/src/codegen/templates/IndexTSTemplate.ts +53 -33
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +130 -124
- package/src/codegen/templates/TurboModuleCppTemplate.ts +54 -47
- package/src/codegen/templates/TurboModuleHTemplate.ts +35 -26
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +90 -81
- package/src/codegen/templates/index.ts +9 -8
- package/src/commands/bundle-harmony.ts +203 -203
- package/src/commands/codegen-harmony.ts +272 -143
- package/src/commands/create-metro-host-constants.ts +48 -48
- package/src/commands/index.ts +6 -6
- package/src/commands/pack-harmony.ts +121 -121
- package/src/commands/unpack-harmony.ts +231 -231
- package/src/commands/verify-package-harmony.ts +106 -106
- package/src/core/AbsolutePath.ts +50 -43
- package/src/core/CodegenConfig.ts +62 -54
- package/src/core/DescriptiveError.ts +61 -61
- package/src/core/OHPackageJSON5.ts +23 -23
- package/src/core/PackageJSON.ts +75 -63
- package/src/core/ProjectDependenciesManager.ts +77 -77
- package/src/core/ValidationError.ts +1 -1
- package/src/core/ValueObject.ts +2 -2
- package/src/core/fs.ts +31 -31
- package/src/core/index.ts +9 -9
- package/src/index.ts +20 -20
- package/src/io/Logger.ts +68 -68
- package/src/io/TarGz.ts +26 -26
- package/src/io/fsUtils.ts +24 -24
- package/src/io/index.ts +3 -3
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +28 -28
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +24 -24
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +18 -18
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +47 -47
- package/src/package-verifier/checks/index.ts +4 -4
- package/src/package-verifier/index.ts +2 -2
- package/src/package-verifier/types.ts +12 -12
- package/src/package-verifier/verify-package.ts +117 -117
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/dist/assetResolver.js +0 -41
- package/dist/codegen/core/Codegen.js +0 -35
- package/dist/codegen/core/CodegenError.js +0 -7
- package/dist/codegen/core/EventUtils.js +0 -19
- package/dist/codegen/core/TypeAnnotationToTS.js +0 -132
- package/dist/codegen/core/UberSchema.js +0 -74
- package/dist/codegen/core/index.js +0 -21
- package/dist/codegen/generators/ComponentCodeGenerator.js +0 -66
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +0 -64
- package/dist/codegen/generators/PackageCodeGenerator.js +0 -52
- package/dist/codegen/generators/index.js +0 -19
- package/dist/codegen/index.js +0 -18
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +0 -55
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +0 -78
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -181
- package/dist/codegen/templates/IndexTSTemplate.js +0 -31
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +0 -117
- package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -45
- package/dist/codegen/templates/TurboModuleHTemplate.js +0 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -64
- package/dist/codegen/templates/index.js +0 -24
- package/dist/commands/bundle-harmony.js +0 -179
- package/dist/commands/codegen-harmony.js +0 -110
- package/dist/commands/create-metro-host-constants.js +0 -61
- package/dist/commands/index.js +0 -22
- package/dist/commands/pack-harmony.js +0 -100
- package/dist/commands/unpack-harmony.js +0 -184
- package/dist/commands/verify-package-harmony.js +0 -127
- package/dist/core/AbsolutePath.js +0 -41
- package/dist/core/CodegenConfig.js +0 -53
- package/dist/core/DescriptiveError.js +0 -49
- package/dist/core/OHPackageJSON5.js +0 -23
- package/dist/core/PackageJSON.js +0 -53
- package/dist/core/ProjectDependenciesManager.js +0 -70
- package/dist/core/ValidationError.js +0 -6
- package/dist/core/ValueObject.js +0 -2
- package/dist/core/fs.js +0 -36
- package/dist/core/index.js +0 -25
- package/dist/index.js +0 -14
- package/dist/io/Logger.js +0 -71
- package/dist/io/TarGz.js +0 -28
- package/dist/io/fsUtils.js +0 -23
- package/dist/io/index.js +0 -19
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +0 -38
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +0 -32
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +0 -26
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +0 -51
- package/dist/package-verifier/checks/index.js +0 -20
- package/dist/package-verifier/index.js +0 -18
- package/dist/package-verifier/types.js +0 -2
- package/dist/package-verifier/verify-package.js +0 -100
- package/src/codegen/core/Codegen.ts +0 -44
- package/src/codegen/generators/PackageCodeGenerator.ts +0 -73
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.commandUnpackHarmony = void 0;
|
|
16
|
-
const io_1 = require("../io");
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const fs_1 = __importDefault(require("fs"));
|
|
19
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
20
|
-
const tar_1 = __importDefault(require("tar"));
|
|
21
|
-
const json5_1 = __importDefault(require("json5"));
|
|
22
|
-
const core_1 = require("../core");
|
|
23
|
-
exports.commandUnpackHarmony = {
|
|
24
|
-
name: 'unpack-harmony',
|
|
25
|
-
description: 'Unpacks native code.',
|
|
26
|
-
options: [
|
|
27
|
-
{
|
|
28
|
-
name: '--project-root-path <path>',
|
|
29
|
-
description: 'Relative path to package root',
|
|
30
|
-
default: '.',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: '--output-dir <string>',
|
|
34
|
-
description: 'Output directory to which OH modules should be unpacked to',
|
|
35
|
-
default: './harmony/rnoh_modules',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
try {
|
|
40
|
-
yield unpack(new core_1.AbsolutePath(args.projectRootPath), new core_1.AbsolutePath(args.outputDir));
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
if (err instanceof core_1.ValidationError) {
|
|
44
|
-
console.error('[ERROR]', err.message);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
};
|
|
53
|
-
function unpack(projectRootPath, outputDirPath) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const logger = new io_1.Logger();
|
|
56
|
-
const projectDependenciesManager = new core_1.ProjectDependenciesManager(projectRootPath);
|
|
57
|
-
logger.info((styles) => styles.bold(`Unpacking RNOH modules`), {
|
|
58
|
-
prefix: true,
|
|
59
|
-
});
|
|
60
|
-
let unpackedArchivesCount = 0;
|
|
61
|
-
let skippedArchivesCount = 0;
|
|
62
|
-
yield projectDependenciesManager.forEachAsync((dependency) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const packageJSON = dependency.readPackageJSON();
|
|
64
|
-
const harmonyArchivePath = dependency
|
|
65
|
-
.getRootPath()
|
|
66
|
-
.copyWithNewSegment('harmony.tar.gz');
|
|
67
|
-
const pkgHarmonyDirPath = dependency
|
|
68
|
-
.getRootPath()
|
|
69
|
-
.copyWithNewSegment('harmony');
|
|
70
|
-
const harmonyTarGzPathStr = dependency
|
|
71
|
-
.getRootPath()
|
|
72
|
-
.copyWithNewSegment('harmony.tar.gz')
|
|
73
|
-
.relativeTo(projectRootPath)
|
|
74
|
-
.getValue();
|
|
75
|
-
if (packageJSON.version &&
|
|
76
|
-
shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, packageJSON.version)) {
|
|
77
|
-
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue())) {
|
|
78
|
-
/**
|
|
79
|
-
* After fresh install, harmony.tar.gz wasn't unpacked to harmony. Updating npm package should remove unpacked harmony dir.
|
|
80
|
-
*/
|
|
81
|
-
logger.info((styles) => `[${styles.cyan('unpacking')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
82
|
-
yield unpackTarGz(harmonyArchivePath, pkgHarmonyDirPath);
|
|
83
|
-
unpackedArchivesCount++;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
skippedArchivesCount++;
|
|
87
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
88
|
-
}
|
|
89
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
90
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
91
|
-
const moduleArchivePathStr = dependency
|
|
92
|
-
.getRootPath()
|
|
93
|
-
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
94
|
-
.relativeTo(projectRootPath)
|
|
95
|
-
.getValue();
|
|
96
|
-
logger.info((styles) => `[${styles.cyan('unpacking')}] ${styles.gray(moduleArchivePathStr)}`);
|
|
97
|
-
unpackedArchivesCount++;
|
|
98
|
-
yield unpackTarGz(ohModuleInfo.archivePath, ohModuleInfo.computedModulePath);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
if (fs_1.default.existsSync(harmonyArchivePath.getValue())) {
|
|
103
|
-
skippedArchivesCount++;
|
|
104
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
105
|
-
}
|
|
106
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
107
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
108
|
-
const moduleArchivePathStr = dependency
|
|
109
|
-
.getRootPath()
|
|
110
|
-
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
111
|
-
.relativeTo(projectRootPath)
|
|
112
|
-
.getValue();
|
|
113
|
-
skippedArchivesCount++;
|
|
114
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(moduleArchivePathStr)}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}));
|
|
118
|
-
logger.info((styles) => `\nUnpacked: ${styles.cyan(unpackedArchivesCount)}, Skipped: ${styles.yellow(skippedArchivesCount)}`);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, nodePackageVersion) {
|
|
122
|
-
if (!fs_1.default.existsSync(harmonyArchivePath.getValue()))
|
|
123
|
-
return false;
|
|
124
|
-
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
125
|
-
return true;
|
|
126
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
127
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
128
|
-
if (!fs_1.default.existsSync(ohModuleInfo.computedModulePath.getValue()) ||
|
|
129
|
-
getOhPackageVersion(ohModuleInfo.computedModulePath) !==
|
|
130
|
-
nodePackageVersion) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
function getOhPackageVersion(modulePath) {
|
|
137
|
-
const ohPackagePath = modulePath.copyWithNewSegment('oh-package.json5');
|
|
138
|
-
if (!fs_1.default.existsSync(ohPackagePath.getValue()))
|
|
139
|
-
return null;
|
|
140
|
-
const content = fs_1.default.readFileSync(ohPackagePath.getValue(), {
|
|
141
|
-
encoding: 'utf-8',
|
|
142
|
-
});
|
|
143
|
-
return json5_1.default.parse(content)['version'];
|
|
144
|
-
}
|
|
145
|
-
function getOhModulesInfo(pkgHarmonyDirPath, outputDirPath) {
|
|
146
|
-
const results = [];
|
|
147
|
-
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
148
|
-
return [];
|
|
149
|
-
const names = fs_1.default.readdirSync(pkgHarmonyDirPath.getValue());
|
|
150
|
-
for (const name of names) {
|
|
151
|
-
if (name.endsWith('.tar.gz')) {
|
|
152
|
-
const archivePath = pkgHarmonyDirPath.copyWithNewSegment(name);
|
|
153
|
-
const computedModuleName = path_1.default
|
|
154
|
-
.parse(archivePath.getValue())
|
|
155
|
-
.name.split('.')[0];
|
|
156
|
-
const computedModulePath = outputDirPath.copyWithNewSegment(computedModuleName);
|
|
157
|
-
results.push({
|
|
158
|
-
archivePath,
|
|
159
|
-
archiveFileName: name,
|
|
160
|
-
computedModulePath,
|
|
161
|
-
computedModuleName,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return results;
|
|
166
|
-
}
|
|
167
|
-
function unpackTarGz(archivePath, outputDirPath) {
|
|
168
|
-
if (!fs_1.default.existsSync(outputDirPath.getValue())) {
|
|
169
|
-
fs_1.default.mkdirSync(outputDirPath.getValue(), { recursive: true });
|
|
170
|
-
}
|
|
171
|
-
const readStream = fs_1.default.createReadStream(archivePath.getValue());
|
|
172
|
-
const writeStream = tar_1.default.extract({
|
|
173
|
-
cwd: outputDirPath.getValue(),
|
|
174
|
-
});
|
|
175
|
-
readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
|
|
176
|
-
return new Promise((resolve, reject) => {
|
|
177
|
-
writeStream.on('finish', () => {
|
|
178
|
-
resolve(undefined);
|
|
179
|
-
});
|
|
180
|
-
writeStream.on('error', (err) => {
|
|
181
|
-
reject(err);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.commandVerifyPackageHarmony = void 0;
|
|
23
|
-
const cli_tools_1 = require("@react-native-community/cli-tools");
|
|
24
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
25
|
-
const core_1 = require("../core");
|
|
26
|
-
const io_1 = require("../io");
|
|
27
|
-
const package_verifier_1 = require("../package-verifier");
|
|
28
|
-
exports.commandVerifyPackageHarmony = {
|
|
29
|
-
name: 'verify-package-harmony',
|
|
30
|
-
description: 'Validates that a package is compliant with guidelines',
|
|
31
|
-
options: [
|
|
32
|
-
{
|
|
33
|
-
name: '--package-path <path>',
|
|
34
|
-
description: 'Path to the npm package',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: '--no-harmony-code [boolean]',
|
|
38
|
-
description: 'Disable har verification',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: '--skip-checks <string>',
|
|
42
|
-
description: 'Disable certain checks by their names separated by ";"',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
func: (argv, config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
var _a, e_1, _b, _c;
|
|
47
|
-
const loader = (0, cli_tools_1.getLoader)();
|
|
48
|
-
try {
|
|
49
|
-
const args = validateArgs(rawArgs);
|
|
50
|
-
loader.info(`Verifying RNOH package: ${args.packagePath.getValue()}`);
|
|
51
|
-
const checkResults = [];
|
|
52
|
-
try {
|
|
53
|
-
for (var _d = true, _e = __asyncValues((0, package_verifier_1.verifyRNOHPackage)({
|
|
54
|
-
npmPackagePath: args.packagePath,
|
|
55
|
-
hasHarmonyCode: args.hasHarmonyCode,
|
|
56
|
-
checkNamesToSkip: args.checkNamesToSkip,
|
|
57
|
-
})), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
58
|
-
_c = _f.value;
|
|
59
|
-
_d = false;
|
|
60
|
-
try {
|
|
61
|
-
const checkResult = _c;
|
|
62
|
-
if (checkResult.type === 'START_PROCESS') {
|
|
63
|
-
loader.start(chalk_1.default.gray(checkResult.name));
|
|
64
|
-
}
|
|
65
|
-
else if (checkResult.type === 'FINISHED_CHECKING') {
|
|
66
|
-
checkResults.push(checkResult);
|
|
67
|
-
logCheckResult(loader, checkResult);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
_d = true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
76
|
-
finally {
|
|
77
|
-
try {
|
|
78
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
79
|
-
}
|
|
80
|
-
finally { if (e_1) throw e_1.error; }
|
|
81
|
-
}
|
|
82
|
-
if (checkResults.every((checkResult) => checkResult.status === 'pass' || checkResult.status === 'skip')) {
|
|
83
|
-
loader.info(chalk_1.default.bold('OK'));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
loader.info(chalk_1.default.red('Package verification failed. Please fix those checks before publishing your package.'));
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
if (err instanceof core_1.DescriptiveError) {
|
|
92
|
-
new io_1.Logger().descriptiveError(err);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
throw err;
|
|
96
|
-
}
|
|
97
|
-
}),
|
|
98
|
-
};
|
|
99
|
-
function validateArgs(args) {
|
|
100
|
-
var _a;
|
|
101
|
-
if (!args.packagePath) {
|
|
102
|
-
throw new core_1.DescriptiveError({
|
|
103
|
-
whatHappened: 'package-path is undefined',
|
|
104
|
-
whatCanUserDo: { default: ['Please provide --package-path'] },
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
packagePath: new core_1.AbsolutePath(args.packagePath),
|
|
109
|
-
hasHarmonyCode: args.harmonyCode,
|
|
110
|
-
checkNamesToSkip: ((_a = args.skipChecks) !== null && _a !== void 0 ? _a : '').split(';'),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function logCheckResult(loader, checkResult) {
|
|
114
|
-
const prefix = (() => {
|
|
115
|
-
switch (checkResult.status) {
|
|
116
|
-
case 'pass':
|
|
117
|
-
return `${chalk_1.default.green('PASS')}`;
|
|
118
|
-
case 'fail':
|
|
119
|
-
return `${chalk_1.default.red('FAIL')}`;
|
|
120
|
-
case 'skip':
|
|
121
|
-
return `${chalk_1.default.yellow('SKIP')}`;
|
|
122
|
-
}
|
|
123
|
-
})();
|
|
124
|
-
loader.info(checkResult.message
|
|
125
|
-
? `[${chalk_1.default.bold(prefix)}] ${chalk_1.default.bold(checkResult.name)}\n${checkResult.message}`
|
|
126
|
-
: `[${chalk_1.default.bold(prefix)}] ${chalk_1.default.bold(checkResult.name)}`);
|
|
127
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AbsolutePath = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
class AbsolutePath {
|
|
9
|
-
static fromSegments(...segments) {
|
|
10
|
-
return new AbsolutePath(node_path_1.default.join(...segments));
|
|
11
|
-
}
|
|
12
|
-
constructor(path) {
|
|
13
|
-
this.value = '';
|
|
14
|
-
this.value = node_path_1.default.resolve(path);
|
|
15
|
-
}
|
|
16
|
-
getValue() {
|
|
17
|
-
return this.value;
|
|
18
|
-
}
|
|
19
|
-
copyWithNewSegment(...relativePath) {
|
|
20
|
-
return new AbsolutePath(node_path_1.default.join(this.getValue(), ...relativePath));
|
|
21
|
-
}
|
|
22
|
-
getExtension() {
|
|
23
|
-
const maybeExtWithDot = node_path_1.default.extname(this.value);
|
|
24
|
-
if (maybeExtWithDot) {
|
|
25
|
-
return maybeExtWithDot.substring(1);
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
relativeTo(absolutePath) {
|
|
30
|
-
return new RelativePath(node_path_1.default.relative(absolutePath.getValue(), this.value));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.AbsolutePath = AbsolutePath;
|
|
34
|
-
class RelativePath {
|
|
35
|
-
constructor(value) {
|
|
36
|
-
this.value = value;
|
|
37
|
-
}
|
|
38
|
-
getValue() {
|
|
39
|
-
return this.value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CodegenConfig = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const io_1 = require("../io");
|
|
9
|
-
const DescriptiveError_1 = require("./DescriptiveError");
|
|
10
|
-
class CodegenConfig {
|
|
11
|
-
static fromRawCodegenConfig(rawCodegenConfig, packageRootPath, projectRootPath, packageName) {
|
|
12
|
-
var _a;
|
|
13
|
-
const SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
|
|
14
|
-
const specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map((rawSpecPath) => {
|
|
15
|
-
if (rawSpecPath.startsWith('~')) {
|
|
16
|
-
return projectRootPath.copyWithNewSegment(rawSpecPath.replace('~', ''));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return packageRootPath.copyWithNewSegment(rawSpecPath);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const specFilePaths = specPaths.flatMap((specPath) => {
|
|
23
|
-
if (!node_fs_1.default.existsSync(specPath.getValue())) {
|
|
24
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
25
|
-
whatHappened: `No such file or directory: ${specPath.getValue()}`,
|
|
26
|
-
whatCanUserDo: {
|
|
27
|
-
default: [
|
|
28
|
-
`Please verify in "${packageName}/package.json::harmony::codegenConfig". If you are not the maintainer of this package, please report this problem to the package maintainer.`,
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (node_fs_1.default.lstatSync(specPath.getValue()).isDirectory()) {
|
|
34
|
-
return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const ext = specPath.getExtension();
|
|
38
|
-
if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
|
|
39
|
-
return [specPath];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return new CodegenConfig(specFilePaths);
|
|
45
|
-
}
|
|
46
|
-
constructor(specFilePaths) {
|
|
47
|
-
this.specFilePaths = specFilePaths;
|
|
48
|
-
}
|
|
49
|
-
getSpecFilePaths() {
|
|
50
|
-
return this.specFilePaths;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.CodegenConfig = CodegenConfig;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DescriptiveError = void 0;
|
|
4
|
-
class DescriptiveError extends Error {
|
|
5
|
-
constructor(data) {
|
|
6
|
-
super(data.whatHappened);
|
|
7
|
-
this.data = data;
|
|
8
|
-
}
|
|
9
|
-
isUnexpected() {
|
|
10
|
-
return 'unexpected' in this.data;
|
|
11
|
-
}
|
|
12
|
-
getMessage() {
|
|
13
|
-
return this.data.whatHappened;
|
|
14
|
-
}
|
|
15
|
-
getSuggestionsByRole() {
|
|
16
|
-
if ('whatCanUserDo' in this.data) {
|
|
17
|
-
return this.data.whatCanUserDo;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
getDetails() {
|
|
24
|
-
var _a;
|
|
25
|
-
if (!this.data.extraData) {
|
|
26
|
-
return '';
|
|
27
|
-
}
|
|
28
|
-
if (typeof this.data.extraData === 'string') {
|
|
29
|
-
return this.data.extraData.trim();
|
|
30
|
-
}
|
|
31
|
-
if (this.data.extraData instanceof Error) {
|
|
32
|
-
let lines = [
|
|
33
|
-
`${this.data.extraData.name}: ${this.data.extraData.message}`,
|
|
34
|
-
];
|
|
35
|
-
for (let stackEntry of ((_a = this.data.extraData.stack) !== null && _a !== void 0 ? _a : '').split('\n')) {
|
|
36
|
-
lines.push('');
|
|
37
|
-
lines.push(stackEntry);
|
|
38
|
-
}
|
|
39
|
-
return lines.join('\n');
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
return JSON.stringify(this.data.extraData, null, 2);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
return '';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.DescriptiveError = DescriptiveError;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OHPackageJSON5 = void 0;
|
|
7
|
-
const json5_1 = __importDefault(require("json5"));
|
|
8
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
-
class OHPackageJSON5 {
|
|
10
|
-
static fromPath(ohPackageJson5Path) {
|
|
11
|
-
return new OHPackageJSON5(json5_1.default.parse(node_fs_1.default.readFileSync(ohPackageJson5Path.getValue(), { encoding: 'utf-8' })));
|
|
12
|
-
}
|
|
13
|
-
constructor(rawData) {
|
|
14
|
-
this.rawData = rawData;
|
|
15
|
-
}
|
|
16
|
-
get name() {
|
|
17
|
-
return this.rawData['name'];
|
|
18
|
-
}
|
|
19
|
-
get version() {
|
|
20
|
-
return this.rawData['version'];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.OHPackageJSON5 = OHPackageJSON5;
|
package/dist/core/PackageJSON.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PackageJSON = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const CodegenConfig_1 = require("./CodegenConfig");
|
|
9
|
-
const DescriptiveError_1 = require("./DescriptiveError");
|
|
10
|
-
class PackageJSON {
|
|
11
|
-
static fromProjectRootPath(packageRootPath, projectRootPath) {
|
|
12
|
-
const packageJSONPath = packageRootPath.copyWithNewSegment('package.json');
|
|
13
|
-
if (!fs_1.default.existsSync(packageJSONPath.getValue())) {
|
|
14
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
15
|
-
whatHappened: "Couldn't find 'package.json'",
|
|
16
|
-
whatCanUserDo: {
|
|
17
|
-
default: [
|
|
18
|
-
'Check if the path to project root is correct',
|
|
19
|
-
'Try changing working directory to project root',
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
extraData: packageJSONPath.getValue(),
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return new PackageJSON(JSON.parse(fs_1.default.readFileSync(packageJSONPath.getValue()).toString()), packageRootPath, projectRootPath);
|
|
26
|
-
}
|
|
27
|
-
constructor(rawPackageJSON, packageRootPath, projectRootPath) {
|
|
28
|
-
this.rawPackageJSON = rawPackageJSON;
|
|
29
|
-
this.packageRootPath = packageRootPath;
|
|
30
|
-
this.projectRootPath = projectRootPath;
|
|
31
|
-
}
|
|
32
|
-
get name() {
|
|
33
|
-
return this.rawPackageJSON.name;
|
|
34
|
-
}
|
|
35
|
-
get version() {
|
|
36
|
-
return this.rawPackageJSON.version;
|
|
37
|
-
}
|
|
38
|
-
maybeCreateCodegenConfig() {
|
|
39
|
-
var _a;
|
|
40
|
-
/**
|
|
41
|
-
* Shared codegenConfig is not used on purpose. Android, iOS and other platforms shouldn't
|
|
42
|
-
* generate code for harmony-specific packages. The shape of this codegenConfig is different
|
|
43
|
-
* that the shape of the shared config, to allow specifying which specific turbo modules or
|
|
44
|
-
* fabric components should be code generated.
|
|
45
|
-
*/
|
|
46
|
-
const rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
|
|
47
|
-
if (!rawCodegenConfig) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(rawCodegenConfig, this.packageRootPath, this.projectRootPath, this.name);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.PackageJSON = PackageJSON;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ProjectDependenciesManager = exports.ProjectDependency = void 0;
|
|
16
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
-
const PackageJSON_1 = require("./PackageJSON");
|
|
18
|
-
class ProjectDependency {
|
|
19
|
-
constructor(packageRootPath, projectRootPath) {
|
|
20
|
-
this.packageRootPath = packageRootPath;
|
|
21
|
-
this.projectRootPath = projectRootPath;
|
|
22
|
-
}
|
|
23
|
-
getRootPath() {
|
|
24
|
-
return this.packageRootPath;
|
|
25
|
-
}
|
|
26
|
-
maybeCreateCodegenConfig() {
|
|
27
|
-
return this.readPackageJSON().maybeCreateCodegenConfig();
|
|
28
|
-
}
|
|
29
|
-
readPackageJSON() {
|
|
30
|
-
return PackageJSON_1.PackageJSON.fromProjectRootPath(this.packageRootPath, this.projectRootPath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.ProjectDependency = ProjectDependency;
|
|
34
|
-
class ProjectDependenciesManager {
|
|
35
|
-
constructor(projectRootPath) {
|
|
36
|
-
this.projectRootPath = projectRootPath;
|
|
37
|
-
}
|
|
38
|
-
forEachAsync(cb) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
yield this.forEachDependencyInDirectory(cb, this.projectRootPath.copyWithNewSegment('node_modules'));
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
forEachDependencyInDirectory(cb, directoryPath) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (!node_fs_1.default.existsSync(directoryPath.getValue())) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (let dirOrFileName of node_fs_1.default.readdirSync(directoryPath.getValue())) {
|
|
49
|
-
const potentialDependencyRootPath = directoryPath.copyWithNewSegment(dirOrFileName);
|
|
50
|
-
if (node_fs_1.default.lstatSync(potentialDependencyRootPath.getValue()).isDirectory()) {
|
|
51
|
-
if (dirOrFileName.startsWith('.')) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
else if (dirOrFileName.startsWith('@')) {
|
|
55
|
-
yield this.forEachDependencyInDirectory(cb, directoryPath.copyWithNewSegment(dirOrFileName));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
if (!node_fs_1.default.existsSync(potentialDependencyRootPath
|
|
59
|
-
.copyWithNewSegment('package.json')
|
|
60
|
-
.getValue())) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
yield cb(new ProjectDependency(potentialDependencyRootPath, this.projectRootPath));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.ProjectDependenciesManager = ProjectDependenciesManager;
|
package/dist/core/ValueObject.js
DELETED
package/dist/core/fs.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.maybeRemoveFilesInDirectory = exports.maybeMakeDirectories = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const DescriptiveError_1 = require("./DescriptiveError");
|
|
9
|
-
function maybeMakeDirectories(path) {
|
|
10
|
-
if (!node_fs_1.default.existsSync(path.getValue())) {
|
|
11
|
-
node_fs_1.default.mkdirSync(path.getValue(), { recursive: true });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.maybeMakeDirectories = maybeMakeDirectories;
|
|
15
|
-
function maybeRemoveFilesInDirectory(path) {
|
|
16
|
-
if (!node_fs_1.default.existsSync(path.getValue())) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!node_fs_1.default.lstatSync(path.getValue()).isDirectory()) {
|
|
20
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
21
|
-
whatHappened: "Tried to remove all files from a path that doesn't point to a directory",
|
|
22
|
-
whatCanUserDo: { default: [`Verify path: ${path.getValue()}`] },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const fileOrDirNames = node_fs_1.default.readdirSync(path.getValue());
|
|
26
|
-
fileOrDirNames.forEach((fileOrDirName) => {
|
|
27
|
-
const maybeFilePath = path.copyWithNewSegment(fileOrDirName);
|
|
28
|
-
if (node_fs_1.default.statSync(maybeFilePath.getValue()).isDirectory()) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
node_fs_1.default.unlinkSync(maybeFilePath.getValue());
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
exports.maybeRemoveFilesInDirectory = maybeRemoveFilesInDirectory;
|