Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task & schema migrations #1488

Merged
merged 6 commits into from Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Expand Up @@ -3,4 +3,7 @@ module.exports = {
settings: {
'import/core-modules': ['@flexn/eslint-config'],
},
rules: {
'@typescript-eslint/no-empty-interface': 'warn',
},
};
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -80,7 +80,10 @@ renative.local.json
renative.local.json
renative.build.json
renative.runtime.json
rnv-config.local.json
rnv.private.json
rnv.local.json
rnv.build.json
rnv.runtime.json
metro.config.local.js
platformBuilds
platformAssets
Expand Down
9 changes: 4 additions & 5 deletions .prettierignore
Expand Up @@ -5,16 +5,15 @@ node_modules
.next
.vscode

appConfigs
appConfigs/**/*
platformBuilds
platformAssets
renative.local.json
renative.private.json
renative.build.json
renative.runtime.json
rnv-config.local.json
metro.config.local.js

!/**/*/renative.json
!/**/*/rnv.json

coverage
build

Expand Down
52 changes: 37 additions & 15 deletions buildHooks/src/prePublish.ts
Expand Up @@ -34,11 +34,13 @@ const VERSIONED_PACKAGES = [
'sdk-react-native',
'sdk-kaios',
'sdk-tizen',
'sdk-telemetry',
'sdk-webos',
'sdk-utils',
'renative',
'config-templates',
'integration-docker',
'integration-starter',
'adapter',
];

Expand All @@ -48,6 +50,8 @@ type PackageConfig = {
pkgPath?: string;
pkgFile?: any;
rnvFile?: any;
rnvTempPath?: string;
rnvTempFile?: any;
};

type PackageConfigs = Record<string, PackageConfig>;
Expand Down Expand Up @@ -92,24 +96,36 @@ const updatePkgDeps = (
};

const updateRenativeDeps = (pkgConfig: PackageConfig, packageName: string, packageConfigs: PackageConfigs) => {
const { rnvFile } = pkgConfig;
const { rnvFile, rnvTempFile } = pkgConfig;
const newVer = packageConfigs[packageName].pkgFile?.version;
let hasRnvChanges = false;

if (rnvFile) {
let hasRnvChanges = false;
const templateVer = rnvFile?.templates?.[packageName]?.version;
const doUpdate = (obj: any, key: string) => {
const templateVer = obj?.[key];
if (templateVer) {
const newVer = `${packageConfigs[packageName].pkgFile?.version}`;
if (templateVer !== newVer) {
console.log('Found linked plugin dependency to update:', packageName, templateVer, newVer);
hasRnvChanges = true;
rnvFile.templates[packageName].version = newVer;
obj[key] = newVer;
}
}
};

if (rnvFile) {
doUpdate(rnvFile?.templates?.[packageName], 'version');
doUpdate(rnvFile?.templateConfig, 'version');
if (hasRnvChanges) {
const output = fixPackageObject(rnvFile);
writeFileSync(pkgConfig.rnvPath, output, 4, true);
}
}
if (rnvTempFile) {
doUpdate(rnvTempFile?.templateConfig?.package_json?.devDependencies, packageName);
if (hasRnvChanges) {
const output = fixPackageObject(rnvTempFile);
writeFileSync(pkgConfig.rnvTempPath, output, 4, true);
}
}
};

export const prePublish = async (c: RnvContext) => {
Expand All @@ -120,13 +136,7 @@ export const prePublish = async (c: RnvContext) => {

const pkgDirPath = path.join(c.paths.project.dir, 'packages');

_updateJson(path.join(pkgDirPath, 'rnv/pluginTemplates/renative.plugins.json'), {
pluginTemplates: {
'@rnv/renative': v,
},
});

_updateJson(path.join(pkgDirPath, 'core/renative.templates.json'), {
_updateJson(path.join(pkgDirPath, 'config-templates/renative.templates.json'), {
engineTemplates: {
'@rnv/engine-rn': v,
'@rnv/engine-rn-tvos': v,
Expand All @@ -137,6 +147,9 @@ export const prePublish = async (c: RnvContext) => {
'@rnv/engine-rn-macos': v,
'@rnv/engine-rn-windows': v,
},
pluginTemplates: {
'@rnv/renative': v,
},
});

const dirs = fs.readdirSync(pkgDirPath);
Expand All @@ -146,10 +159,12 @@ export const prePublish = async (c: RnvContext) => {

const parsePackages = (dirPath: string) => {
let pkgName: string | undefined;
let rnvPath;
let _pkgPath;
let rnvFile;
let pkgFile;
let rnvPath;
let rnvFile;
let rnvTempPath;
let rnvTempFile;

if (fs.statSync(dirPath).isDirectory()) {
_pkgPath = path.join(dirPath, RnvFileName.package);
Expand All @@ -162,6 +177,11 @@ export const prePublish = async (c: RnvContext) => {
rnvPath = _rnvPath;
rnvFile = readObjectSync(rnvPath);
}
const _rnvTempPath = path.join(dirPath, 'renative.template.json');
if (fsExistsSync(_rnvTempPath)) {
rnvTempPath = _rnvTempPath;
rnvTempFile = readObjectSync(rnvTempPath);
}
}
if (pkgName) {
packageConfigs[pkgName] = {
Expand All @@ -170,6 +190,8 @@ export const prePublish = async (c: RnvContext) => {
pkgPath: _pkgPath,
pkgFile,
rnvFile,
rnvTempPath,
rnvTempFile,
};
packageNamesAll.push(pkgName);
}
Expand Down