UNPKG

@nxrocks/nx-flutter

Version:

Nx plugin adding first class support for Flutter in your Nx workspace

67 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFlutterInstalled = isFlutterInstalled; exports.isFlutterProject = isFlutterProject; exports.quote = quote; exports.buildFlutterCreateOptions = buildFlutterCreateOptions; const fileutils_1 = require("@nx/workspace/src/utilities/fileutils"); const common_1 = require("@nxrocks/common"); const child_process_1 = require("child_process"); function isFlutterInstalled(useFvm = false) { try { (0, child_process_1.execSync)(`${useFvm == true ? 'fvm ' : ''}flutter --version`, { stdio: ['ignore', 'ignore', 'ignore'], }); return true; } catch (e) { return false; } } function isFlutterProject(project) { return (0, fileutils_1.fileExists)((0, common_1.getProjectFilePath)(project, 'pubspec.yaml')); } function quote(text) { if (!text || (text.startsWith('"') && text.endsWith('"'))) { return text; } else { return `"${text.replace('"', '\\"')}"`; } } function buildFlutterCreateOptions(options) { const keyValueParams = [ { key: 'project-name', value: options.projectName.replace(new RegExp('[-.]', 'g'), '_'), }, { key: 'org', value: options.org }, { key: 'description', value: quote(options.description) }, { key: 'android-language', value: options.androidLanguage }, { key: 'ios-language', value: options.iosLanguage }, { key: 'template', value: options.template }, { key: 'sample', value: options.sample }, { key: 'platforms', value: options.platforms ? quote(options.platforms.join(',')) : null, }, ].filter((e) => !!e.value); let opts = keyValueParams.map((e) => `--${e.key}=${e.value}`).join(' '); const boolParams = [ { key: 'pub', value: options.pub }, { key: 'offline', value: options.offline }, ].filter((e) => !!e.value); opts += ' ' + boolParams .map((e) => { if (e.value === true) return `--${e.key}`; else if (e.value === false) return `--no-${e.key}`; return ''; }) .join(' '); return opts; } //# sourceMappingURL=flutter-utils.js.map