@react-native-oh/react-native-harmony-cli 0.0.26 → 0.0.27
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/dist/assetResolver.js +19 -0
- package/dist/codegen/core/CodeGenerator.js +2 -0
- package/dist/codegen/core/CodegenError.js +7 -0
- package/dist/codegen/core/EventUtils.js +19 -0
- package/dist/codegen/core/TypeAnnotationToTS.js +132 -0
- package/dist/codegen/core/UberSchema.js +103 -0
- package/dist/codegen/core/index.js +21 -0
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +61 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +76 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +74 -0
- package/dist/codegen/generators/CppComponentCodeGenerator.js +56 -0
- package/dist/codegen/generators/LibGlueCodeGenerator.js +50 -0
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +73 -0
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +34 -0
- package/dist/codegen/generators/UberGeneratorV1.js +50 -0
- package/dist/codegen/generators/UberGeneratorV2.js +71 -0
- package/dist/codegen/generators/index.js +24 -0
- package/dist/codegen/index.js +18 -0
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +105 -0
- package/dist/codegen/templates/BasePackageHTemplate.js +130 -0
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +62 -0
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +85 -0
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +192 -0
- package/dist/codegen/templates/IndexTSTemplate.js +52 -0
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +124 -0
- package/dist/codegen/templates/TurboModuleCppTemplate.js +53 -0
- package/dist/codegen/templates/TurboModuleHTemplate.js +42 -0
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +75 -0
- package/dist/codegen/templates/index.js +25 -0
- package/dist/commands/bundle-harmony.js +179 -0
- package/dist/commands/codegen-harmony.js +201 -0
- package/dist/commands/codegen-lib-harmony.js +253 -0
- package/dist/commands/create-metro-host-constants.js +61 -0
- package/dist/commands/index.js +23 -0
- package/dist/commands/pack-harmony.js +100 -0
- package/dist/commands/unpack-harmony.js +184 -0
- package/dist/commands/verify-package-harmony.js +122 -0
- package/dist/core/AbsolutePath.js +47 -0
- package/dist/core/CodegenConfig.js +57 -0
- package/dist/core/DescriptiveError.js +49 -0
- package/dist/core/OHPackageJSON5.js +23 -0
- package/dist/core/PackageJSON.js +58 -0
- package/dist/core/ProjectDependenciesManager.js +70 -0
- package/dist/core/ValidationError.js +6 -0
- package/dist/core/ValueObject.js +2 -0
- package/dist/core/fs.js +36 -0
- package/dist/core/index.js +25 -0
- package/dist/index.js +15 -0
- package/dist/io/Logger.js +71 -0
- package/dist/io/TarGz.js +28 -0
- package/dist/io/fsUtils.js +23 -0
- package/dist/io/index.js +19 -0
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +38 -0
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +32 -0
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +26 -0
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +51 -0
- package/dist/package-verifier/checks/index.js +20 -0
- package/dist/package-verifier/index.js +18 -0
- package/dist/package-verifier/types.js +2 -0
- package/dist/package-verifier/verify-package.js +101 -0
- package/package.json +1 -1
- package/src/codegen/core/UberSchema.ts +4 -0
- package/src/codegen/generators/{GlueCodeGenerator.ts → AppBuildTimeGlueCodeGenerator.ts} +13 -9
- package/src/codegen/generators/{ComponentCodeGeneratorArkTS.ts → ArkTSComponentCodeGeneratorArkTS.ts} +11 -5
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +112 -0
- package/src/codegen/generators/{ComponentCodeGeneratorCAPI.ts → CppComponentCodeGenerator.ts} +14 -43
- package/src/codegen/generators/LibGlueCodeGenerator.ts +91 -0
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +7 -5
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +50 -0
- package/src/codegen/generators/UberGeneratorV1.ts +12 -8
- package/src/codegen/generators/UberGeneratorV2.ts +32 -16
- package/src/codegen/generators/index.ts +5 -3
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +12 -7
- package/src/codegen/templates/{GeneratedPackageHTemplate.ts → BasePackageHTemplate.ts} +45 -12
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +2 -1
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +8 -10
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +13 -8
- package/src/codegen/templates/IndexTSTemplate.ts +11 -9
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +1 -0
- package/src/codegen/templates/TurboModuleCppTemplate.ts +9 -9
- package/src/codegen/templates/TurboModuleHTemplate.ts +9 -9
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +13 -9
- package/src/commands/codegen-harmony.ts +24 -7
- package/src/commands/codegen-lib-harmony.ts +387 -0
- package/src/commands/index.ts +1 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
getCodegenConfigs() {
|
|
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 [];
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(rawCodegenConfig)) {
|
|
51
|
+
return rawCodegenConfig.map((config) => CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, this.packageRootPath, this.projectRootPath, this.name));
|
|
52
|
+
}
|
|
53
|
+
return [
|
|
54
|
+
CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(rawCodegenConfig, this.packageRootPath, this.projectRootPath, this.name),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PackageJSON = PackageJSON;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
getCodegenConfigs() {
|
|
27
|
+
return this.readPackageJSON().getCodegenConfigs();
|
|
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/fs.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AbsolutePath"), exports);
|
|
18
|
+
__exportStar(require("./ValidationError"), exports);
|
|
19
|
+
__exportStar(require("./DescriptiveError"), exports);
|
|
20
|
+
__exportStar(require("./ValueObject"), exports);
|
|
21
|
+
__exportStar(require("./PackageJSON"), exports);
|
|
22
|
+
__exportStar(require("./ProjectDependenciesManager"), exports);
|
|
23
|
+
__exportStar(require("./CodegenConfig"), exports);
|
|
24
|
+
__exportStar(require("./fs"), exports);
|
|
25
|
+
__exportStar(require("./OHPackageJSON5"), exports);
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = void 0;
|
|
4
|
+
const commands_1 = require("./commands");
|
|
5
|
+
exports.config = {
|
|
6
|
+
commands: [
|
|
7
|
+
commands_1.commandBundleHarmony,
|
|
8
|
+
commands_1.commandPackHarmony,
|
|
9
|
+
commands_1.commandUnpackHarmony,
|
|
10
|
+
commands_1.commandCreateMetroConstantsHarmony,
|
|
11
|
+
commands_1.commandCodegenHarmony,
|
|
12
|
+
commands_1.commandVerifyPackageHarmony,
|
|
13
|
+
commands_1.commandCodegenLibHarmony,
|
|
14
|
+
],
|
|
15
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
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.Logger = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
class Logger {
|
|
9
|
+
info(prepareMsg, options) {
|
|
10
|
+
const prefix = (options === null || options === void 0 ? void 0 : options.prefix) ? `[${chalk_1.default.bold(chalk_1.default.cyan('INFO'))}]` : '';
|
|
11
|
+
if (prefix) {
|
|
12
|
+
console.info(prefix, prepareMsg(chalk_1.default));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.info(prepareMsg(chalk_1.default));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
debug(prepareMsg) {
|
|
19
|
+
console.debug(prepareMsg(chalk_1.default));
|
|
20
|
+
}
|
|
21
|
+
descriptiveError(error) {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
23
|
+
const lines = [];
|
|
24
|
+
if (error.isUnexpected() && error.stack) {
|
|
25
|
+
lines.push('');
|
|
26
|
+
lines.push(chalk_1.default.bold('Stack'));
|
|
27
|
+
error.stack.split('\n').forEach((line) => lines.push(chalk_1.default.gray(line)));
|
|
28
|
+
}
|
|
29
|
+
const details = error.getDetails();
|
|
30
|
+
if (details) {
|
|
31
|
+
lines.push('');
|
|
32
|
+
lines.push(chalk_1.default.bold('Details'));
|
|
33
|
+
details.split('\n').forEach((line) => lines.push(line));
|
|
34
|
+
}
|
|
35
|
+
lines.push('');
|
|
36
|
+
let prefix = '';
|
|
37
|
+
if (error.isUnexpected()) {
|
|
38
|
+
prefix = '[' + chalk_1.default.red(chalk_1.default.bold('UNEXPECTED_ERROR')) + ']';
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
prefix = '[' + chalk_1.default.red(chalk_1.default.bold('ERROR')) + ']';
|
|
42
|
+
}
|
|
43
|
+
lines.push(`${prefix} ${error.getMessage()}`);
|
|
44
|
+
const suggestionsByRole = error.getSuggestionsByRole();
|
|
45
|
+
if (suggestionsByRole) {
|
|
46
|
+
if (((_b = (_a = suggestionsByRole.default) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
47
|
+
lines.push('');
|
|
48
|
+
lines.push(chalk_1.default.bold(`Suggestions`));
|
|
49
|
+
(_c = suggestionsByRole.default) === null || _c === void 0 ? void 0 : _c.forEach((suggestion) => {
|
|
50
|
+
lines.push(suggestion);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (((_e = (_d = suggestionsByRole.rnAppDeveloper) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) > 0) {
|
|
54
|
+
lines.push('');
|
|
55
|
+
lines.push(chalk_1.default.bold(`Suggestions for RN App developers`));
|
|
56
|
+
(_f = suggestionsByRole.rnAppDeveloper) === null || _f === void 0 ? void 0 : _f.forEach((suggestion) => {
|
|
57
|
+
lines.push(suggestion);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if ((_h = (_g = suggestionsByRole.rnPackageDeveloper) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) {
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push(chalk_1.default.bold(`Suggestions for RN package developers`));
|
|
63
|
+
(_j = suggestionsByRole.rnPackageDeveloper) === null || _j === void 0 ? void 0 : _j.forEach((suggestion) => {
|
|
64
|
+
lines.push(suggestion);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
console.error(lines.join('\n'));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.Logger = Logger;
|
package/dist/io/TarGz.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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.unpackTarGz = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
9
|
+
const tar_1 = __importDefault(require("tar"));
|
|
10
|
+
function unpackTarGz(archivePath, outputDirPath) {
|
|
11
|
+
if (!node_fs_1.default.existsSync(outputDirPath.getValue())) {
|
|
12
|
+
node_fs_1.default.mkdirSync(outputDirPath.getValue(), { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
const readStream = node_fs_1.default.createReadStream(archivePath.getValue());
|
|
15
|
+
const writeStream = tar_1.default.extract({
|
|
16
|
+
cwd: outputDirPath.getValue(),
|
|
17
|
+
});
|
|
18
|
+
readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
writeStream.on('finish', () => {
|
|
21
|
+
resolve(undefined);
|
|
22
|
+
});
|
|
23
|
+
writeStream.on('error', (err) => {
|
|
24
|
+
reject(err);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.unpackTarGz = unpackTarGz;
|
|
@@ -0,0 +1,23 @@
|
|
|
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.findFilePathsWithExtensions = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
function findFilePathsWithExtensions(dirPath, fileExtensions) {
|
|
10
|
+
let results = [];
|
|
11
|
+
const files = node_fs_1.default.readdirSync(dirPath.getValue(), { withFileTypes: true });
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const path = dirPath.copyWithNewSegment(file.name);
|
|
14
|
+
if (file.isDirectory()) {
|
|
15
|
+
results = results.concat(findFilePathsWithExtensions(path, fileExtensions));
|
|
16
|
+
}
|
|
17
|
+
else if (fileExtensions.includes(node_path_1.default.extname(file.name).substring(1))) {
|
|
18
|
+
results.push(path);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
exports.findFilePathsWithExtensions = findFilePathsWithExtensions;
|
package/dist/io/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Logger"), exports);
|
|
18
|
+
__exportStar(require("./fsUtils"), exports);
|
|
19
|
+
__exportStar(require("./TarGz"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
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.createHarmonyDirContainsOnlyHarsCheck = void 0;
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
function createHarmonyDirContainsOnlyHarsCheck(npmPackagePath, hasNpmPackageNativeCode) {
|
|
18
|
+
return {
|
|
19
|
+
checkIf: 'harmony_directory_contains_only_one_har_file',
|
|
20
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (!hasNpmPackageNativeCode) {
|
|
22
|
+
return 'skip';
|
|
23
|
+
}
|
|
24
|
+
const harmonyPath = npmPackagePath
|
|
25
|
+
.copyWithNewSegment('harmony')
|
|
26
|
+
.getValue();
|
|
27
|
+
const fileOrDirNames = node_fs_1.default.readdirSync(harmonyPath);
|
|
28
|
+
if (fileOrDirNames.length !== 1) {
|
|
29
|
+
return { status: 'fail', message: JSON.stringify(fileOrDirNames) };
|
|
30
|
+
}
|
|
31
|
+
if (!fileOrDirNames[0].endsWith('.har')) {
|
|
32
|
+
return 'fail';
|
|
33
|
+
}
|
|
34
|
+
return 'pass';
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.createHarmonyDirContainsOnlyHarsCheck = createHarmonyDirContainsOnlyHarsCheck;
|
|
@@ -0,0 +1,32 @@
|
|
|
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.createHarmonyDirExistsCheck = void 0;
|
|
16
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
17
|
+
function createHarmonyDirExistsCheck(packagePath, hasNativeCode) {
|
|
18
|
+
return {
|
|
19
|
+
checkIf: 'package_has_harmony_dir',
|
|
20
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const harmonyDirExist = node_fs_1.default.existsSync(packagePath.copyWithNewSegment('harmony').getValue());
|
|
22
|
+
if (!hasNativeCode) {
|
|
23
|
+
return 'skip';
|
|
24
|
+
}
|
|
25
|
+
if (!harmonyDirExist) {
|
|
26
|
+
return 'fail';
|
|
27
|
+
}
|
|
28
|
+
return 'pass';
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.createHarmonyDirExistsCheck = createHarmonyDirExistsCheck;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createNpmAndOhPackageVersionsAreEqualCheck = void 0;
|
|
13
|
+
function createNpmAndOhPackageVersionsAreEqualCheck(npmPackageVersion, ohPackageVersion) {
|
|
14
|
+
return {
|
|
15
|
+
checkIf: 'npm_and_oh_package_versions_are_equal',
|
|
16
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return npmPackageVersion === ohPackageVersion
|
|
18
|
+
? 'pass'
|
|
19
|
+
: {
|
|
20
|
+
status: 'fail',
|
|
21
|
+
message: `expected OH package version (${ohPackageVersion}) to match NPM version (${npmPackageVersion})`,
|
|
22
|
+
};
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.createNpmAndOhPackageVersionsAreEqualCheck = createNpmAndOhPackageVersionsAreEqualCheck;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createOhPackageNameFollowsNamingConventionCheck = void 0;
|
|
13
|
+
function createOhPackageNameFollowsNamingConventionCheck(npmPackageName, ohPackageName) {
|
|
14
|
+
const npmPackageNameInfo = getPackageNameInfo(npmPackageName);
|
|
15
|
+
return {
|
|
16
|
+
checkIf: 'oh_package_name_is_derived_from_npm_package_name',
|
|
17
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (npmPackageNameInfo.organizationName) {
|
|
19
|
+
const expectedOHPackageName = `@rnoh/${npmPackageNameInfo.organizationName}--${npmPackageNameInfo.unscopedName}`;
|
|
20
|
+
return expectedOHPackageName === ohPackageName
|
|
21
|
+
? 'pass'
|
|
22
|
+
: {
|
|
23
|
+
status: 'fail',
|
|
24
|
+
message: `expected '${expectedOHPackageName}', got: ${ohPackageName}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const expectedOHPackageName = `@rnoh/${npmPackageNameInfo.unscopedName}`;
|
|
29
|
+
return expectedOHPackageName === ohPackageName
|
|
30
|
+
? 'pass'
|
|
31
|
+
: {
|
|
32
|
+
status: 'fail',
|
|
33
|
+
message: `expected '${expectedOHPackageName}', got: ${ohPackageName}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.createOhPackageNameFollowsNamingConventionCheck = createOhPackageNameFollowsNamingConventionCheck;
|
|
40
|
+
function getPackageNameInfo(packageName) {
|
|
41
|
+
if (packageName.startsWith('@') && packageName.includes('/')) {
|
|
42
|
+
const [part1, part2] = packageName.split('/');
|
|
43
|
+
return {
|
|
44
|
+
organizationName: part1.replace('@', ''),
|
|
45
|
+
unscopedName: part2,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return { organizationName: null, unscopedName: packageName };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./HarmonyDirExistsCheck"), exports);
|
|
18
|
+
__exportStar(require("./HarmonyDirContainsOnlyHarsCheck"), exports);
|
|
19
|
+
__exportStar(require("./NpmAnAndOhPackageVersionsAreEqual"), exports);
|
|
20
|
+
__exportStar(require("./OhPackageNameFollowsNamingConventionCheck"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./verify-package"), exports);
|