-
Notifications
You must be signed in to change notification settings - Fork 149
[generator-macos] Use CocoaPods to build iOS and macOS targets #298
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
Changes from all commits
5a421ed
91fd31d
bb8f3d4
a296e60
87d589d
53ea1c5
7f1f035
880787a
4e068db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
// @ts-check | ||
|
||
const fs = require('fs'); | ||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
const copyAndReplace = require('@react-native-community/cli/build/tools/copyAndReplace').default; | ||
const walk = require('@react-native-community/cli/build/tools/walk').default; | ||
const prompt = require('@react-native-community/cli/build/tools/generator/promptSync').default(); | ||
|
||
/** | ||
* @param {string} destPath | ||
*/ | ||
function createDir(destPath) { | ||
if (!fs.existsSync(destPath)) { | ||
fs.mkdirSync(destPath); | ||
fs.mkdirSync(destPath, { recursive: true }); | ||
} | ||
} | ||
|
||
/** | ||
* @todo Move this upstream to @react-native-community/cli | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are we tracking this work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Iβll be touching the CLI package for the next iteration of this when I make auto-linking work and will make this change then. |
||
* | ||
* @param {string} templatePath | ||
* @param {Record<string, string>} replacements | ||
*/ | ||
function replaceInPath(templatePath, replacements) { | ||
let result = templatePath; | ||
Object.keys(replacements).forEach(key => { | ||
result = result.replace(key, replacements[key]); | ||
}); | ||
return result; | ||
} | ||
|
||
function copyAndReplaceWithChangedCallback(srcPath, destRoot, relativeDestPath, replacements, alwaysOverwrite) { | ||
if (!replacements) { | ||
replacements = {}; | ||
|
@@ -35,15 +54,23 @@ function copyAndReplaceWithChangedCallback(srcPath, destRoot, relativeDestPath, | |
); | ||
} | ||
|
||
/** | ||
* @param {string} srcPath | ||
* @param {string} destPath | ||
* @param {string} relativeDestDir | ||
* @param {Record<string, string>} replacements | ||
* @param {boolean} alwaysOverwrite | ||
*/ | ||
function copyAndReplaceAll(srcPath, destPath, relativeDestDir, replacements, alwaysOverwrite) { | ||
walk(srcPath).forEach(absoluteSrcFilePath => { | ||
const filename = path.relative(srcPath, absoluteSrcFilePath); | ||
const relativeDestPath = path.join(relativeDestDir, filename); | ||
const relativeDestPath = path.join(relativeDestDir, replaceInPath(filename, replacements)); | ||
copyAndReplaceWithChangedCallback(absoluteSrcFilePath, destPath, relativeDestPath, replacements, alwaysOverwrite); | ||
}); | ||
} | ||
|
||
function alwaysOverwriteContentChangedCallback( absoluteSrcFilePath, | ||
function alwaysOverwriteContentChangedCallback( | ||
absoluteSrcFilePath, | ||
relativeDestPath, | ||
contentChanged | ||
) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.