mirror of
https://github.com/status-im/react-native-desktop-qt-init.git
synced 2025-02-20 14:18:17 +00:00
initial commit
This commit is contained in:
parent
0a48445cbf
commit
5013901aba
5
bin.js
Normal file
5
bin.js
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Yarn will fail to link workspace binaries if they haven't been built yet. Add
|
||||
// a simple JS file to forward to the CLI which is built after install.
|
||||
require('./src/cli');
|
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "react-native-desktop-qt-init",
|
||||
"version": "0.1.0",
|
||||
"description": "CLI to bootstrap the addition of desktop-qt platform to existing react-native project",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"bin": {
|
||||
"react-native-desktop-qt-init": "./bin.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vkjr/react-native-desktop-qt-init.git"
|
||||
},
|
||||
"author": "Volodymyr Kozieiev",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vkjr/react-native-desktop-qt-init/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vkjr/react-native-desktop-qt-init#readme",
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.3"
|
||||
}
|
||||
}
|
50
src/cli.js
Normal file
50
src/cli.js
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const chalk = require('chalk');
|
||||
const Common = require('./common');
|
||||
const execSync = require('child_process').execSync;
|
||||
const path = require('path');
|
||||
|
||||
|
||||
const PACKAGE = "git+https://github.com/status-im/react-native-desktop-qt.git#v060";
|
||||
|
||||
const REACT_NATIVE_DESKTOP_GENERATE_PATH = function() {
|
||||
return path.resolve(
|
||||
process.cwd(),
|
||||
'node_modules',
|
||||
'react-native-desktop-qt',
|
||||
'local-cli',
|
||||
'generate-desktop.js'
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
function installDesktopPackage() {
|
||||
let rndPackage = PACKAGE;
|
||||
|
||||
console.log(`Installing ${rndPackage}...`);
|
||||
const pkgmgr = Common.isGlobalCliUsingYarn(process.cwd()) ? 'yarn add' : 'npm install --save';
|
||||
const execOptions = {}; // use {stdio: 'inherit'} for verbose
|
||||
execSync(`${pkgmgr} ${rndPackage}`, execOptions);
|
||||
console.log(chalk.green(`${rndPackage} successfully installed.`));
|
||||
}
|
||||
|
||||
function runDesktopFilesGenerationScript() {
|
||||
|
||||
const generateDesktop = require(REACT_NATIVE_DESKTOP_GENERATE_PATH());
|
||||
generateDesktop(process.cwd(), Common.getReactNativeAppName());
|
||||
}
|
||||
|
||||
|
||||
(async () => {
|
||||
|
||||
try {
|
||||
installDesktopPackage();
|
||||
|
||||
runDesktopFilesGenerationScript();
|
||||
} catch (error) {
|
||||
console.error(chalk.red(error.message));
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
31
src/common.js
Normal file
31
src/common.js
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
|
||||
const isGlobalCliUsingYarn = function(projectDir) {
|
||||
return fs.existsSync(path.join(projectDir, 'yarn.lock'));
|
||||
};
|
||||
|
||||
|
||||
const getReactNativeAppName = function () {
|
||||
console.log('Reading application name from package.json...');
|
||||
let name = JSON.parse(fs.readFileSync('package.json', 'utf8')).name;
|
||||
if (!name) {
|
||||
if (fs.existsSync('app.json')) {
|
||||
console.log('Reading application name from app.json...');
|
||||
name = JSON.parse(fs.readFileSync('app.json', 'utf8')).name;
|
||||
}
|
||||
}
|
||||
if (!name) {
|
||||
console.error('Please specify name in package.json or app.json');
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isGlobalCliUsingYarn,
|
||||
getReactNativeAppName,
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user