diff --git a/packages/cycle-scripts/configs/dependencies.js b/packages/cycle-scripts/configs/dependencies.js new file mode 100644 index 0000000..85790ad --- /dev/null +++ b/packages/cycle-scripts/configs/dependencies.js @@ -0,0 +1,23 @@ +module.exports = { + basics: [ + '@cycle/dom@17.1.0' + ], + language: { + javascript: [], + typescript: [] + }, + streamLib: { + xstream: [ + '@cycle/run@3.1.0', + 'xstream@10.5.0' + ], + rxjs: [ + '@cycle/rxjs-run@7.0.0', + 'rxjs@5.3.0' + ], + most: [ + '@cycle/most-run@7.1.0', + 'most@1.2.2' + ] + } +} diff --git a/packages/cycle-scripts/configs/flavor.js b/packages/cycle-scripts/configs/flavor.js deleted file mode 100644 index ad88c61..0000000 --- a/packages/cycle-scripts/configs/flavor.js +++ /dev/null @@ -1,46 +0,0 @@ -const dependencies = { - basics: [ - '@cycle/dom@17.1.0' - ], - language: { - 'javascript': [], - 'typescript': [] - }, - streamLib: { - xstream: [ - '@cycle/run@3.1.0', - 'xstream@10.5.0' - ], - rxjs: [ - '@cycle/rxjs-run@7.0.0', - 'rxjs@5.3.0' - ], - most: [ - '@cycle/most-run@7.1.0', - 'most@1.2.2' - ] - } -} - -const replacements = { - xstream: { - run: '@cycle/run', - import: 'import xs from \'xstream\'', - stream: 'xs' - }, - rxjs: { - run: '@cycle/rxjs-run', - import: 'import Rx from \'rxjs/Rx\'', - stream: 'Rx.Observable' - }, - most: { - run: '@cycle/most-run', - import: 'import * as most from \'most\'', - stream: 'most' - } -} - -module.exports = { - dependencies, - replacements -} diff --git a/packages/cycle-scripts/scripts/init/setup.js b/packages/cycle-scripts/scripts/init/setup.js index 233f485..b0d7fb8 100644 --- a/packages/cycle-scripts/scripts/init/setup.js +++ b/packages/cycle-scripts/scripts/init/setup.js @@ -5,7 +5,7 @@ const path = require('path') const chalk = require('chalk') const spawn = require('cross-spawn') -const flavorConfig = require('../../configs/flavor') +const dependencies = require('../../configs/dependencies') const success = require('./success') module.exports = function setup (appPath, appName, options) { @@ -16,7 +16,7 @@ module.exports = function setup (appPath, appName, options) { // STEP #1 - Create boilerplate files const flavorPath = path.join(appPath, 'node_modules', 'cycle-scripts') - const templateStrings = flavorConfig.replacements + const templateStrings = require(path.join(flavorPath, 'template/config', language + '.js')) const templatePath = path.join(flavorPath, 'template/src', language) // Create ./public directory fs.ensureDirSync(path.join(appPath, 'public')) @@ -69,12 +69,12 @@ module.exports = function setup (appPath, appName, options) { // Gather together all the dependencies needed for the flavor // Taking into consideration user choices for language and stream library // All the dependency locks and configurations can be found in /configs/flavor.js - const basicDependencies = flavorConfig.dependencies.basics - const languageDependencies = flavorConfig.dependencies.language[language] - const streamLibDependencies = flavorConfig.dependencies.streamLib[streamLib] + const basicDependencies = dependencies.basics + const streamLibDependencies = dependencies.streamLib[streamLib] + const languageDependencies = dependencies.language[language] const dependenciesToInstall = basicDependencies - .concat(languageDependencies) .concat(streamLibDependencies) + .concat(languageDependencies) const dependecyList = dependenciesToInstall .slice(0, (dependenciesToInstall.length - 1)) .join(', ') diff --git a/packages/cycle-scripts/template/config/javascript.js b/packages/cycle-scripts/template/config/javascript.js new file mode 100644 index 0000000..59aa083 --- /dev/null +++ b/packages/cycle-scripts/template/config/javascript.js @@ -0,0 +1,17 @@ +module.exports = { + xstream: { + run: '@cycle/run', + import: 'import xs from \'xstream\'', + stream: 'xs' + }, + rxjs: { + run: '@cycle/rxjs-run', + import: 'import Rx from \'rxjs/Rx\'', + stream: 'Rx.Observable' + }, + most: { + run: '@cycle/most-run', + import: 'import * as most from \'most\'', + stream: 'most' + } +} diff --git a/packages/cycle-scripts/template/config/typescript.js b/packages/cycle-scripts/template/config/typescript.js new file mode 100644 index 0000000..cf5a995 --- /dev/null +++ b/packages/cycle-scripts/template/config/typescript.js @@ -0,0 +1,23 @@ +module.exports = { + xstream: { + run: '@cycle/run', + import: 'import xs from \'xstream\'', + typeImport: 'import {Stream} from \'xstream\'', + stream: 'xs', + streamType: 'Stream' + }, + rxjs: { + run: '@cycle/rxjs-run', + import: 'import Rx from \'rxjs/Rx\'', + typeImport: 'import {Observable} from \'rxjs\'', + stream: 'Rx.Observable', + streamType: 'Observable' + }, + most: { + run: '@cycle/most-run', + import: 'import * as most from \'most\'', + typeImport: 'import {Stream} from \'most\'', + stream: 'most', + streamType: 'Stream' + } +} diff --git a/packages/cycle-scripts/template/src/JavaScript/app.js b/packages/cycle-scripts/template/src/javascript/app.jsx similarity index 100% rename from packages/cycle-scripts/template/src/JavaScript/app.js rename to packages/cycle-scripts/template/src/javascript/app.jsx diff --git a/packages/cycle-scripts/template/src/JavaScript/app.test.js b/packages/cycle-scripts/template/src/javascript/app.test.js similarity index 100% rename from packages/cycle-scripts/template/src/JavaScript/app.test.js rename to packages/cycle-scripts/template/src/javascript/app.test.js diff --git a/packages/cycle-scripts/template/src/JavaScript/index.js b/packages/cycle-scripts/template/src/javascript/index.js similarity index 100% rename from packages/cycle-scripts/template/src/JavaScript/index.js rename to packages/cycle-scripts/template/src/javascript/index.js diff --git a/packages/cycle-scripts/template/src/typescript/app.test.ts b/packages/cycle-scripts/template/src/typescript/app.test.ts new file mode 100644 index 0000000..c9a417a --- /dev/null +++ b/packages/cycle-scripts/template/src/typescript/app.test.ts @@ -0,0 +1,8 @@ +module.exports = replacements => `// import assert from 'assert' + +// describe('App', function () { +// it('should test something', function () { +// // TODO: Add your tests here +// }) +// }) +` diff --git a/packages/cycle-scripts/template/src/typescript/app.tsx b/packages/cycle-scripts/template/src/typescript/app.tsx new file mode 100644 index 0000000..32ab431 --- /dev/null +++ b/packages/cycle-scripts/template/src/typescript/app.tsx @@ -0,0 +1,13 @@ +module.exports = replacements => `${replacements.import} +import {Sources, Sinks} from './interfaces' + +export function App(sources : Sources) : Sinks { + const vtree$ = ${replacements.stream}.of( +