-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #405 from JoeStanton/new-library-cmd
[CLI] New Library Generator
- Loading branch information
Showing
11 changed files
with
433 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Stub of Sample for Android. | ||
* | ||
* @providesModule Sample | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
var warning = require('warning'); | ||
|
||
var Sample = { | ||
test: function() { | ||
warning("Not yet implemented for Android."); | ||
} | ||
}; | ||
|
||
module.exports = Sample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import "RCTBridgeModule.h" | ||
|
||
@interface Sample : NSObject <RCTBridgeModule> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @providesModule Sample | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
var NativeSample = require('NativeModules').Sample; | ||
var invariant = require('invariant'); | ||
|
||
/** | ||
* High-level docs for the Sample iOS API can be written here. | ||
*/ | ||
|
||
var Sample = { | ||
test: function() { | ||
NativeSample.test(); | ||
} | ||
}; | ||
|
||
module.exports = Sample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import "Sample.h" | ||
|
||
@implementation Sample | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
RCT_EXPORT_METHOD(test) | ||
{ | ||
// Your implementation here | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
// !$*UTF8*$! | ||
{ | ||
archiveVersion = 1; | ||
classes = { | ||
}; | ||
objectVersion = 46; | ||
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
13BE3DEE1AC21097009241FE /* Sample.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* Sample.m */; }; | ||
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXCopyFilesBuildPhase section */ | ||
58B511D91A9E6C8500147676 /* CopyFiles */ = { | ||
isa = PBXCopyFilesBuildPhase; | ||
buildActionMask = 2147483647; | ||
dstPath = "include/$(PRODUCT_NAME)"; | ||
dstSubfolderSpec = 16; | ||
files = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXCopyFilesBuildPhase section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
134814201AA4EA6300B7C361 /* libSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSample.a; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
13BE3DEC1AC21097009241FE /* Sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sample.h; sourceTree = "<group>"; }; | ||
13BE3DED1AC21097009241FE /* Sample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sample.m; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
58B511D81A9E6C8500147676 /* Frameworks */ = { | ||
isa = PBXFrameworksBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXFrameworksBuildPhase section */ | ||
|
||
/* Begin PBXGroup section */ | ||
134814211AA4EA7D00B7C361 /* Products */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
134814201AA4EA6300B7C361 /* libSample.a */, | ||
); | ||
name = Products; | ||
sourceTree = "<group>"; | ||
}; | ||
58B511D21A9E6C8500147676 = { | ||
isa = PBXGroup; | ||
children = ( | ||
13BE3DEC1AC21097009241FE /* Sample.h */, | ||
13BE3DED1AC21097009241FE /* Sample.m */, | ||
134814211AA4EA7D00B7C361 /* Products */, | ||
); | ||
sourceTree = "<group>"; | ||
}; | ||
/* End PBXGroup section */ | ||
|
||
/* Begin PBXNativeTarget section */ | ||
58B511DA1A9E6C8500147676 /* Sample */ = { | ||
isa = PBXNativeTarget; | ||
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Sample" */; | ||
buildPhases = ( | ||
58B511D71A9E6C8500147676 /* Sources */, | ||
58B511D81A9E6C8500147676 /* Frameworks */, | ||
58B511D91A9E6C8500147676 /* CopyFiles */, | ||
); | ||
buildRules = ( | ||
); | ||
dependencies = ( | ||
); | ||
name = Sample; | ||
productName = RCTDataManager; | ||
productReference = 134814201AA4EA6300B7C361 /* libSample.a */; | ||
productType = "com.apple.product-type.library.static"; | ||
}; | ||
/* End PBXNativeTarget section */ | ||
|
||
/* Begin PBXProject section */ | ||
58B511D31A9E6C8500147676 /* Project object */ = { | ||
isa = PBXProject; | ||
attributes = { | ||
LastUpgradeCheck = 0610; | ||
ORGANIZATIONNAME = Facebook; | ||
TargetAttributes = { | ||
58B511DA1A9E6C8500147676 = { | ||
CreatedOnToolsVersion = 6.1.1; | ||
}; | ||
}; | ||
}; | ||
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Sample" */; | ||
compatibilityVersion = "Xcode 3.2"; | ||
developmentRegion = English; | ||
hasScannedForEncodings = 0; | ||
knownRegions = ( | ||
en, | ||
); | ||
mainGroup = 58B511D21A9E6C8500147676; | ||
productRefGroup = 58B511D21A9E6C8500147676; | ||
projectDirPath = ""; | ||
projectRoot = ""; | ||
targets = ( | ||
58B511DA1A9E6C8500147676 /* Sample */, | ||
); | ||
}; | ||
/* End PBXProject section */ | ||
|
||
/* Begin PBXSourcesBuildPhase section */ | ||
58B511D71A9E6C8500147676 /* Sources */ = { | ||
isa = PBXSourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
13BE3DEE1AC21097009241FE /* Sample.m in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXSourcesBuildPhase section */ | ||
|
||
/* Begin XCBuildConfiguration section */ | ||
58B511ED1A9E6C8500147676 /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
CLANG_CXX_LIBRARY = "libc++"; | ||
CLANG_ENABLE_MODULES = YES; | ||
CLANG_ENABLE_OBJC_ARC = YES; | ||
CLANG_WARN_BOOL_CONVERSION = YES; | ||
CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
CLANG_WARN_EMPTY_BODY = YES; | ||
CLANG_WARN_ENUM_CONVERSION = YES; | ||
CLANG_WARN_INT_CONVERSION = YES; | ||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
CLANG_WARN_UNREACHABLE_CODE = YES; | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
COPY_PHASE_STRIP = NO; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
GCC_C_LANGUAGE_STANDARD = gnu99; | ||
GCC_DYNAMIC_NO_PIC = NO; | ||
GCC_OPTIMIZATION_LEVEL = 0; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
GCC_SYMBOLS_PRIVATE_EXTERN = NO; | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 7.0; | ||
MTL_ENABLE_DEBUG_INFO = YES; | ||
ONLY_ACTIVE_ARCH = YES; | ||
SDKROOT = iphoneos; | ||
}; | ||
name = Debug; | ||
}; | ||
58B511EE1A9E6C8500147676 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
CLANG_CXX_LIBRARY = "libc++"; | ||
CLANG_ENABLE_MODULES = YES; | ||
CLANG_ENABLE_OBJC_ARC = YES; | ||
CLANG_WARN_BOOL_CONVERSION = YES; | ||
CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
CLANG_WARN_EMPTY_BODY = YES; | ||
CLANG_WARN_ENUM_CONVERSION = YES; | ||
CLANG_WARN_INT_CONVERSION = YES; | ||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
CLANG_WARN_UNREACHABLE_CODE = YES; | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
COPY_PHASE_STRIP = YES; | ||
ENABLE_NS_ASSERTIONS = NO; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
GCC_C_LANGUAGE_STANDARD = gnu99; | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 7.0; | ||
MTL_ENABLE_DEBUG_INFO = NO; | ||
SDKROOT = iphoneos; | ||
VALIDATE_PRODUCT = YES; | ||
}; | ||
name = Release; | ||
}; | ||
58B511F01A9E6C8500147676 /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
HEADER_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, | ||
"$(SRCROOT)/../../React/**", | ||
"$(SRCROOT)/../../node_modules/react-native/React/**", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = Sample; | ||
SKIP_INSTALL = YES; | ||
}; | ||
name = Debug; | ||
}; | ||
58B511F11A9E6C8500147676 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
HEADER_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, | ||
"$(SRCROOT)/../../React/**", | ||
); | ||
LIBRARY_SEARCH_PATHS = "$(inherited)"; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = Sample; | ||
SKIP_INSTALL = YES; | ||
}; | ||
name = Release; | ||
}; | ||
/* End XCBuildConfiguration section */ | ||
|
||
/* Begin XCConfigurationList section */ | ||
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Sample" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
58B511ED1A9E6C8500147676 /* Debug */, | ||
58B511EE1A9E6C8500147676 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Sample" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
58B511F01A9E6C8500147676 /* Debug */, | ||
58B511F11A9E6C8500147676 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
}; | ||
rootObject = 58B511D31A9E6C8500147676 /* Project object */; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Sample", | ||
"version": "0.0.1", | ||
"keywords": "react-native" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
function copyAndReplace(src, dest, replacements) { | ||
if (fs.lstatSync(src).isDirectory()) { | ||
if (!fs.existsSync(dest)) { | ||
fs.mkdirSync(dest); | ||
} | ||
} else { | ||
var content = fs.readFileSync(src, 'utf8'); | ||
Object.keys(replacements).forEach(function(regex) { | ||
content = content.replace(new RegExp(regex, 'g'), replacements[regex]); | ||
}); | ||
fs.writeFileSync(dest, content); | ||
} | ||
} | ||
|
||
function walk(current) { | ||
if (!fs.lstatSync(current).isDirectory()) { | ||
return [current]; | ||
} | ||
|
||
var files = fs.readdirSync(current).map(function(child) { | ||
child = path.join(current, child); | ||
return walk(child); | ||
}); | ||
return [].concat.apply([current], files); | ||
} | ||
|
||
function validatePackageName(name) { | ||
if (!name.match(/^[$A-Z_][0-9A-Z_$]*$/i)) { | ||
console.error( | ||
'"%s" is not a valid name for a project. Please use a valid identifier ' + | ||
'name (alphanumeric).', | ||
name | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
module.exports = { | ||
copyAndReplace: copyAndReplace, | ||
walk: walk, | ||
validatePackageName: validatePackageName | ||
}; |
Oops, something went wrong.