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

Feat - Unified schema #1668

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-androidtv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
# - '**/lerna.json'
# - '**/metadata.json'
# - '**/renative.json'
# - '**/rnv.json'
# - '**/package.json'
# pull_request:
# types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-tvos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-harness-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-androidtv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
# - '**/lerna.json'
# - '**/metadata.json'
# - '**/renative.json'
# - '**/rnv.json'
# - '**/package.json'
# pull_request:
# types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-tvos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-template-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '**/lerna.json'
- '**/metadata.json'
- '**/renative.json'
- '**/rnv.json'
- '**/package.json'
pull_request:
types: [labeled]
Expand Down
4 changes: 2 additions & 2 deletions buildHooks/src/prePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ export const prePublish = async (c: RnvContext) => {
pkgFile = readObjectSync<any>(_pkgPath);
pkgName = pkgFile?.name;
}
const _rnvPath = path.join(dirPath, 'renative.json');
const _rnvPath = path.join(dirPath, RnvFileName.renative);
if (fsExistsSync(_rnvPath)) {
rnvPath = _rnvPath;
rnvFile = readObjectSync(rnvPath);
}
const _rnvTempPath = path.join(dirPath, 'renative.template.json');
const _rnvTempPath = path.join(dirPath, RnvFileName.renativeTemplate);
if (fsExistsSync(_rnvTempPath)) {
rnvTempPath = _rnvTempPath;
rnvTempFile = readObjectSync(rnvTempPath);
Expand Down
40 changes: 20 additions & 20 deletions packages/build-hooks-schema/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import fs from 'fs';

export const generateSchema = async () => {
const {
zodConfigFilePlugin,
zodConfigFilePrivate,
zodConfigFileProject,
zodConfigFileTemplate,
zodConfigFileTemplates,
zodConfigFileWorkspace,
zodConfigFileIntegration,
zodConfigFileApp,
zodConfigFileLocal,
zodConfigFileEngine,
// zodConfigFilePlugin,
// zodConfigFilePrivate,
// zodConfigFileProject,
// zodConfigFileTemplate,
// zodConfigFileTemplates,
// zodConfigFileWorkspace,
// zodConfigFileIntegration,
// zodConfigFileApp,
// zodConfigFileLocal,
// zodConfigFileEngine,
zodConfigFileRoot,
} = ZodFileSchema;
// LEGACY
_generateSchemaFile({ schema: zodConfigFileProject, schemaId: 'rnv.project' });
_generateSchemaFile({ schema: zodConfigFileApp, schemaId: 'rnv.app' });
_generateSchemaFile({ schema: zodConfigFileLocal, schemaId: 'rnv.local' });
_generateSchemaFile({ schema: zodConfigFileEngine, schemaId: 'rnv.engine' });
_generateSchemaFile({ schema: zodConfigFileWorkspace, schemaId: 'rnv.workspace' });
_generateSchemaFile({ schema: zodConfigFileTemplate, schemaId: 'rnv.template' });
_generateSchemaFile({ schema: zodConfigFilePrivate, schemaId: 'rnv.private' });
_generateSchemaFile({ schema: zodConfigFilePlugin, schemaId: 'rnv.plugin' });
_generateSchemaFile({ schema: zodConfigFileTemplates, schemaId: 'rnv.templates' });
_generateSchemaFile({ schema: zodConfigFileIntegration, schemaId: 'rnv.integration' });
// _generateSchemaFile({ schema: zodConfigFileProject, schemaId: 'rnv.project' });
// _generateSchemaFile({ schema: zodConfigFileApp, schemaId: 'rnv.app' });
// _generateSchemaFile({ schema: zodConfigFileLocal, schemaId: 'rnv.local' });
// _generateSchemaFile({ schema: zodConfigFileEngine, schemaId: 'rnv.engine' });
// _generateSchemaFile({ schema: zodConfigFileWorkspace, schemaId: 'rnv.workspace' });
// _generateSchemaFile({ schema: zodConfigFileTemplate, schemaId: 'rnv.template' });
// _generateSchemaFile({ schema: zodConfigFilePrivate, schemaId: 'rnv.private' });
// _generateSchemaFile({ schema: zodConfigFilePlugin, schemaId: 'rnv.plugin' });
// _generateSchemaFile({ schema: zodConfigFileTemplates, schemaId: 'rnv.templates' });
// _generateSchemaFile({ schema: zodConfigFileIntegration, schemaId: 'rnv.integration' });
// CURRENT
const definitions: Record<string, any> = {};
Object.values(ZodSharedSchema).forEach((val) => {
Expand Down
22 changes: 7 additions & 15 deletions packages/core/jsonSchema/renative-1.0.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@
},
"description": "Allows you to inject custom script into html header"
},
"excludedDirs": {
"excludedPaths": {
"type": "array",
"items": {
"type": "string"
Expand Down Expand Up @@ -5279,6 +5279,12 @@
}
}
},
"required": [
"name",
"engineExtension",
"plugins",
"npm"
],
"additionalProperties": false
},
"plugin": {
Expand Down Expand Up @@ -5809,20 +5815,6 @@
"description": "schema definition"
}
},
"required": [
"app",
"project",
"local",
"overrides",
"integration",
"engine",
"plugin",
"private",
"template",
"configTemplates",
"workspace",
"workspaces"
],
"additionalProperties": false
}
},
Expand Down
48 changes: 44 additions & 4 deletions packages/core/src/__tests/_sanity.tstest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
});

// core context must not provide unknown options
// @ts-expect-error

Check warning on line 18 in packages/core/src/__tests/_sanity.tstest.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer
console.log(preset1.UNTYPED);

Check warning on line 19 in packages/core/src/__tests/_sanity.tstest.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

// must provide new options
console.log(preset1.withSet1);
Expand Down Expand Up @@ -204,7 +204,17 @@

const engine1 = createRnvEngine({
tasks: [task1, task2, task3, task4, task5, task6],
config: {},
config: {
engine: {
engineExtension: 'js',
name: 'test',
npm: {},
overview: '',
platforms: {},
plugins: {},
custom: {},
},
},
platforms: {},
});
type GCEngine1 = GetContextType<typeof engine1.getContext>;
Expand Down Expand Up @@ -234,7 +244,17 @@

const engine2 = createRnvEngine({
tasks: [],
config: {},
config: {
engine: {
engineExtension: 'js',
name: 'test',
npm: {},
overview: '',
platforms: {},
plugins: {},
custom: {},
},
},
platforms: {},
});
type GCEngine2 = GetContextType<typeof engine2.getContext>;
Expand All @@ -254,7 +274,17 @@
const engine3 = createRnvEngine({
extendModules: [module1, module3],
tasks: [],
config: {},
config: {
engine: {
engineExtension: 'js',
name: 'test',
npm: {},
overview: '',
platforms: {},
plugins: {},
custom: {},
},
},
platforms: {},
});
type GCEngine3 = GetContextType<typeof engine3.getContext>;
Expand Down Expand Up @@ -289,7 +319,17 @@
const engine4 = createRnvEngine({
extendModules: [module1, module2, module3],
tasks: [task2, task3, task4, task5, task6],
config: {},
config: {
engine: {
engineExtension: 'js',
name: 'test',
npm: {},
overview: '',
platforms: {},
plugins: {},
custom: {},
},
},
platforms: {},
});
type GCEngine4 = GetContextType<typeof engine4.getContext>;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/configs/appConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const listAppConfigsFoldersSync = (ignoreHiddenConfigs: boolean, appConfi
if (fsExistsSync(appConfig)) {
try {
const config = readObjectSync<ConfigFileApp>(appConfig);
if (config?.hidden !== true) {
if (config?.app?.hidden !== true) {
appConfigsDirs.push(dir);
}
} catch (e) {
Expand Down
15 changes: 8 additions & 7 deletions packages/core/src/configs/buildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
fsExistsSync,
formatBytes,
mkdirSync,
writeFileSync
writeFileSync,
} from '../system/fs';
import { chalk, logDefault, logWarning, logDebug } from '../logger';
import { getContext } from '../context/provider';
Expand All @@ -27,16 +27,17 @@ const getEnginesPluginDelta = () => {
const missingEnginePlugins: Record<string, string> = {};

const engineConfig = c.platform ? c.runtime.enginesByPlatform[c.platform]?.config : undefined;
if (engineConfig?.plugins) {
const ePlugins = Object.keys(engineConfig.plugins);
const ePluginVals = engineConfig?.engine?.plugins;
if (ePluginVals) {
const ePlugins = Object.keys(ePluginVals);

if (ePlugins?.length) {
ePlugins.forEach((pluginKey) => {
if (!c.files?.project?.config?.plugins?.[pluginKey] && engineConfig.plugins?.[pluginKey]) {
missingEnginePlugins[pluginKey] = engineConfig.plugins?.[pluginKey];
if (!c.files?.project?.config?.project?.plugins?.[pluginKey] && ePluginVals[pluginKey]) {
missingEnginePlugins[pluginKey] = ePluginVals[pluginKey];
}
if (engineConfig.plugins?.[pluginKey]) {
enginePlugins[pluginKey] = engineConfig.plugins?.[pluginKey];
if (ePluginVals[pluginKey]) {
enginePlugins[pluginKey] = ePluginVals[pluginKey];
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/configs/configProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const upgradeDependencies = (
_fixDeps(packageFile?.devDependencies, version);
_fixDeps(packageFile?.dependencies, version);
_fixDeps(packageFile?.peerDependencies, version);
if (configFile?.templateConfig) {
configFile.templateConfig.version = version;
if (configFile?.projectTemplate?.templateConfig) {
configFile.projectTemplate.templateConfig.version = version;
}

if (packageFile) {
Expand Down Expand Up @@ -86,8 +86,8 @@ export const updateProjectPlatforms = (platforms: Array<RnvPlatformKey>) => {
} = c.paths;
const currentConfig = c.files.project.config;
if (currentConfig) {
currentConfig.defaults = currentConfig.defaults || {};
currentConfig.defaults.supportedPlatforms = platforms;
currentConfig.project.defaults = currentConfig.project.defaults || {};
currentConfig.project.defaults.supportedPlatforms = platforms;
writeFileSync(config, currentConfig);
} else {
logWarning('Config not loaded yet. skipping updateProjectPlatforms');
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const loadFileExtended = (fileObj: Record<string, any>, pathObj: RnvConte
const extendsTemplate = fileObj[key]?.extendsTemplate;
if (key === 'config' && extendsTemplate) {
// extendsTemplate only applies to standard 'config'
let currTemplate = c.files.project[key]?.templateConfig?.name || fileObj[key].templateConfig?.name;
let currTemplate =
c.files.project[key]?.projectTemplate?.templateConfig?.name || fileObj[key].templateConfig?.name;
if (!currTemplate) {
if (extendsTemplate.startsWith('@')) {
currTemplate = extendsTemplate.split('/').slice(0, 2).join('/');
Expand Down Expand Up @@ -285,12 +286,12 @@ export const parseRenativeConfigs = async () => {
}

// LOAD WORKSPACE /[PROJECT_NAME]/RENATIVE.*.JSON
if (!c.files.project.config.projectName) {
if (!c.files.project.config?.project?.projectName) {
return Promise.reject('Your renative.json is missing required property: projectName ');
}
generateContextPaths(
c.paths.workspace.project,
path.join(c.paths.workspace.dir, c.files.project.config.projectName)
path.join(c.paths.workspace.dir, c.files.project.config.project.projectName)
);
_loadConfigFiles(c.files.workspace.project, c.paths.workspace.project);

Expand Down
Loading
Loading