Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
service.path = svcName;
}
service.path = resolve(project.cwd, service.path);
const search = await cosmiconfig('devconfig', {
searchPlaces: [
'.devconfig.yaml',
'.devconfig.yml',
'.devconfig.js',
'.devconfig.json',
],
}).search(service.path);
if (search === null) {
print.info(
`${print.colors.info(
`info`
)} cannot find devconfig file for service ${print.colors.warning(
svcName
)}, using empty default`
);
return service;
// process.exit(1);
}
// resolve each service
await Promise.map(Object.keys(search.config), async keyName => {
const config = search.config[keyName];
async function init(nameProject) {
try {
if (!nameProject) throw 'Please fill your name app. For ex: zkrn init myApp'
print.info('FILE BIN ' + __dirname)
print.info('DEFAULT FOLDER ' + process.cwd())
print.info(`Creating new react-native called ${nameProject}... Will take 5 minutes`)
await installReactNative(nameProject)
print.info('Creating react-native successfully')
print.info('Now install dependence package')
await installPackageDependence(nameProject)
print.info('Copying base component')
await copyBaseToProject(nameProject)
// Link package
print.info('Linking package...')
await linkingPackage(nameProject)
print.info('Done!. Run IOS now')
} catch(err) {
print.error(err)
}
}
async function init(nameProject) {
try {
if (!nameProject) throw 'Please fill your name app. For ex: zkrn init myApp'
print.info('FILE BIN ' + __dirname)
print.info('DEFAULT FOLDER ' + process.cwd())
print.info(`Creating new react-native called ${nameProject}... Will take 5 minutes`)
await installReactNative(nameProject)
print.info('Creating react-native successfully')
print.info('Now install dependence package')
await installPackageDependence(nameProject)
print.info('Copying base component')
await copyBaseToProject(nameProject)
// Link package
print.info('Linking package...')
await linkingPackage(nameProject)
print.info('Done!. Run IOS now')
} catch(err) {
print.error(err)
}
}
async function copyIndexFile(nameProject) {
print.info('Copy index.js file')
const indexFile = `import { AppRegistry } from 'react-native';
import App from './src/mobile';
AppRegistry.registerComponent('${nameProject}', () => App);
`
await exec(`echo "${indexFile}\" > ${process.cwd()}/${nameProject}/index.js`)
}
async function copyBaseToProject(nameProject) {
async function copyAppDelegate(nameProject) {
print.info('Copy App Delegate...')
const appDelegate = String.raw`
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
#import
#import
@implementation AppDelegate
const outputHelp = (message: HelpMessage | string): void => {
if (typeof message === 'string') {
return print.info(message)
}
if (message.description) {
print.info(message.description)
print.newline()
}
print.info('Usage:')
print.info(` $ ${message.usage}`)
if (message.commands) {
print.newline()
print.info('Commands:')
if (message.commands instanceof Array) {
print.table(message.commands)
} else {
})
.version({
name: 'version',
alias: ['-v'],
description: 'Show version',
dashed: true,
run: ({ print: { info }, meta }: RootContext) => {
info(meta.version())
}
})
.create()
try {
await cli.run(argv)
} catch (error) {
print.info(`${print.xmark} Aborted.`)
if (error) {
new PrettyError().render(error)
}
}
}
async function copyBin(nameProject) {
print.info('Copy bin and Makefile')
const changeIp = String.raw`#!/usr/bin/env python3
import re
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((\"8.8.8.8\", 80))
ip = s.getsockname()[0]
s.close()
FILE_IOS = './ios/${nameProject}/AppDelegate.m'
with open(FILE_IOS) as f:
content = f.read()
content_new = re.sub(r'(http:\/\/).*\/', r'http://' + ip + ':8081/', content)
f = open(FILE_IOS, 'w')
f.write(content_new)