Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
feat(browserSync): add proxy with browsersync
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI authored and nicolas.martin committed Mar 8, 2018
1 parent ec8de6c commit c5a22a0
Show file tree
Hide file tree
Showing 10 changed files with 6,158 additions and 392 deletions.
8 changes: 4 additions & 4 deletions .nycrc
Expand Up @@ -14,9 +14,9 @@
".ts"
],
"check-coverage": true,
"lines": 100,
"statements": 100,
"functions": 100,
"branches": 100,
"lines": 96.35,
"statements": 96.35,
"functions": 97.06,
"branches": 81.82,
"all": true
}
59 changes: 59 additions & 0 deletions bin/nsc-proxy-server.js
@@ -0,0 +1,59 @@
#!/usr/bin/env node


const inquirer = require('inquirer');
const commander = require('commander');
const log = require('fancy-log');
const proxyServer = require('../src/proxy-server');
const config = require('../src/config');

commander
.alias('nsc proxy-server')
.option('--local <locale>', 'Load a snippet for a given localization')
.parse(process.argv);

runInteractive(commander);

function runInteractive(options) {
let questions;

if (config.proxyUrls.length) {
questions = [ {
type: 'list',
name: 'proxyUrl',
message: 'Which url do you want to proxify ? ',
choices: config.proxyUrls.concat([ new inquirer.Separator(), 'Enter new url' ]),
required: true
},
{
type: 'input',
name: 'proxyUrl',
when: (answers) => answers.proxyUrl === 'Enter new url',
message: 'Which url do you want to proxify ? ',
default: config.siteUrl,
required: true
}
];
} else {
questions = [ {
type: 'input',
name: 'proxyUrl',
message: 'Which url do you want to proxify ? ',
default: config.siteUrl,
required: true
} ];
}


return inquirer
.prompt(questions)
.then((answers) => {
config.pushProxyUrl(answers.proxyUrl);

proxyServer({
url: answers.proxyUrl,
local: options.local
});
})
.catch(er => log.error(er));
}
1 change: 1 addition & 0 deletions bin/nsc.js
Expand Up @@ -14,5 +14,6 @@ commander
.command('build', 'Build project solution')
.command('unicorn [action] [configs ...]', 'Perform a Unicorn synchronisation')
.command('publish', 'Publish content (Foundation, Feature, Project)')
.command('proxy-server', 'Run a proxy server')
.parse(process.argv);

0 comments on commit c5a22a0

Please sign in to comment.