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

Fix(TemplateStarter): Fix renative icons not appearing for macOS and Web #1530

Merged
merged 4 commits into from
May 2, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"rn-fetch-blob": "0.12.0"
},
"devDependencies": {
"@flexn/assets-renative-outline": "0.3.3",
"@flexn/assets-renative-outline": "0.3.5",
"@flexn/graybox": "1.0.0-feat.12",
"@rnv/cli": "1.0.0-rc.17",
"@rnv/config-templates": "1.0.0-rc.17",
Expand Down
44 changes: 39 additions & 5 deletions packages/core/src/projects/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
return true;
};

export const copyAssetsFolder = async (subPath?: string, customFn?: (c: RnvContext, platform: RnvPlatform) => void) => {
// Copies assets from available sources for a platform
// destPath - can be either absolute or relative to platformBuilds/*_platform dir,
// default is platformBuilds/*_platform dir absolute path
export const copyAssetsFolder = async (
destPath?: string,
customFn?: (c: RnvContext, platform: RnvPlatform) => void
) => {
logDefault('copyAssetsFolder');

const c = getContext();
Expand Down Expand Up @@ -79,7 +85,8 @@
});
}

const destPath = path.join(getPlatformProjectDir()!, subPath || '');
const destinationPath =
!!destPath && path.isAbsolute(destPath) ? destPath : path.join(getPlatformProjectDir()!, destPath || '');

Check warning on line 89 in packages/core/src/projects/assets.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Forbidden non-null assertion
const hasExternalAssets = validAssetSources.length > 0;

// FOLDER MERGERS FROM EXTERNAL SOURCES
Expand All @@ -90,7 +97,16 @@
)}. Will be used to generate assets.`
);
validAssetSources.forEach((sourcePath) => {
copyFolderContentsRecursiveSync(sourcePath, destPath, true, undefined, false, undefined, tsPathsConfig, c);
copyFolderContentsRecursiveSync(
sourcePath,
destinationPath,
true,
undefined,
false,
undefined,
tsPathsConfig,
c
);
});
}

Expand All @@ -117,11 +133,29 @@
if (c.paths.appConfig.dirs) {
c.paths.appConfig.dirs.forEach((v) => {
const sourcePath = path.join(v, `assets/${assetFolderPlatform}`);
copyFolderContentsRecursiveSync(sourcePath, destPath, true, undefined, false, undefined, tsPathsConfig, c);
copyFolderContentsRecursiveSync(
sourcePath,
destinationPath,
true,
undefined,
false,
undefined,
tsPathsConfig,
c
);
});
} else {
const sourcePath = path.join(c.paths.appConfig.dir, `assets/${assetFolderPlatform}`);
copyFolderContentsRecursiveSync(sourcePath, destPath, true, undefined, false, undefined, tsPathsConfig, c);
copyFolderContentsRecursiveSync(
sourcePath,
destinationPath,
true,
undefined,
false,
undefined,
tsPathsConfig,
c
);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/engine-rn-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@rnv/sdk-utils": "1.0.0-rc.17",
"@rnv/sdk-webpack": "1.0.0-rc.17",
"electron": "26.3.0",
"electron-builder": "24.6.4",
"electron-builder": "24.13.3",
"electron-notarize": "1.2.2",
"metro-react-native-babel-preset": "0.76.8"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-rn-electron/src/sdk/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const configureProject = (exitOnFail?: boolean) =>
height: 800,
webPreferences: { nodeIntegration: true, enableRemoteModule: true, contextIsolation: false },
icon:
(platform === 'macos' || platform === 'linux') && !fsExistsSync(pngIconPath)
platform === 'linux' && !fsExistsSync(pngIconPath)
? path.join(platformProjectDir, 'resources', 'icon.icns')
: path.join(platformProjectDir, 'resources', 'icon.png'),
};
Expand Down
14 changes: 1 addition & 13 deletions packages/engine-rn-next/src/sdk/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
RnvContext,
executeAsync,
getConfigProp,
copyFolderContentsRecursiveSync,
chalk,
logDefault,
logInfo,
Expand All @@ -28,19 +27,8 @@ export const configureNextIfRequired = async () => {

c.runtime.platformBuildsProjectPath = `${getAppFolder()}`;

await copyAssetsFolder();

const destPath = path.join(c.paths.project.dir, 'public');

if (c.paths.appConfig.dirs) {
c.paths.appConfig.dirs.forEach((v) => {
const sourcePath = path.join(v, `assets/${c.platform}`);
copyFolderContentsRecursiveSync(sourcePath, destPath);
});
} else {
const sourcePath = path.join(c.paths.appConfig.dir, `assets/${c.platform}`);
copyFolderContentsRecursiveSync(sourcePath, destPath);
}
await copyAssetsFolder(destPath);
};

export const runWebNext = async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/template-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"watch": "tsc --watch --preserveWatchOutput --noEmit"
},
"devDependencies": {
"@flexn/assets-renative-outline": "0.3.3",
"@flexn/assets-renative-outline": "0.3.5",
"@flexn/graybox": "1.0.0-feat.12",
"@lightningjs/sdk": "5.5.1",
"@rnv/adapter": "1.0.0-rc.17",
Expand Down
7 changes: 3 additions & 4 deletions packages/template-starter/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
"minSdkVersion": 21,
"extendPlatform": "android",
"engine": "engine-rn-tvos",
"includedPermissions": [
"INTERNET"
]
"includedPermissions": ["INTERNET"]
},
"web": {
"engine": "engine-rn-next"
Expand All @@ -96,7 +94,8 @@
"reactNativeEngine": "hermes"
},
"macos": {
"engine": "engine-rn-electron"
"engine": "engine-rn-electron",
"assetFolderPlatform": "electron"
},
"windows": {
"engine": "engine-rn-electron"
Expand Down
57 changes: 10 additions & 47 deletions packages/template-starter/renative.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,16 @@
]
},
{
"paths": [
"Gemfile",
"metro.config.js",
".bundle",
"react-native.config.js"
],
"platforms": [
"ios",
"android",
"tvos",
"firetv",
"androidtv"
]
"paths": ["Gemfile", "metro.config.js", ".bundle", "react-native.config.js"],
"platforms": ["ios", "android", "tvos", "firetv", "androidtv"]
},
{
"paths": [
"next.config.js",
"next-env.d.ts",
"src/pages"
],
"platforms": [
"web"
]
"paths": ["next.config.js", "next-env.d.ts", "src/pages"],
"platforms": ["web"]
},
{
"paths": [
"webpack.config.js"
],
"platforms": [
"macos",
"tizen",
"webos",
"tizenwatch",
"tizenmobile"
]
"paths": ["webpack.config.js"],
"platforms": ["macos", "tizen", "webos", "tizenwatch", "tizenmobile"]
}
],
"renative_json": {
Expand All @@ -68,23 +43,15 @@
"@types/react-dom": "18.2.18",
"@types/react-native": "0.72.3",
"@flexn/typescript-config": "1.0.0",
"@flexn/assets-renative-outline": "0.3.3",
"@flexn/assets-renative-outline": "0.3.5",
"@rnv/core": "1.0.0-rc.17",
"@rnv/cli": "1.0.0-rc.17",
"@rnv/adapter": "1.0.0-rc.17",
"@rnv/config-templates": "1.0.0-rc.17"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"production": [">0.2%", "not dead", "not op_mini all"],
"development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
}
}
},
Expand All @@ -93,10 +60,6 @@
"pkg-dir": "7.0.0",
"xmlbuilder": "^15.1.1"
},
"defaultSelectedPlatforms": [
"web",
"ios",
"android"
]
"defaultSelectedPlatforms": ["web", "ios", "android"]
}
}
2 changes: 1 addition & 1 deletion packages/template-starter/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MyDocument extends Document {
<Html lang="en">
<Head>
<meta name="description" content={CONFIG.welcomeMessage} />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="icon" href="/images/favicon.ico" sizes="any" />
</Head>
<body>
<Main />
Expand Down
Loading
Loading