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

Commit

Permalink
feat(publish): Add publish tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed May 11, 2018
1 parent 9f88fac commit 7b4422e
Show file tree
Hide file tree
Showing 10 changed files with 710 additions and 179 deletions.
6 changes: 3 additions & 3 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
".ts"
],
"check-coverage": true,
"lines": 96.23,
"statements": 96.25,
"functions": 97.06,
"lines": 90.4,
"statements": 90.45,
"functions": 89.47,
"branches": 78.57,
"all": true
}
4 changes: 2 additions & 2 deletions bin/nsc-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commander
.alias('nsc build')
.usage('[options]')
.option(
' -a, --architecture <arch>',
'-a, --architecture <arch>',
'Specify the Architecture (Auto-detected, x86, x84)'
)
.option(
Expand Down Expand Up @@ -84,7 +84,7 @@ const options = {
Platform: solutionPlatform,
...solutionProperties
},
customArgs: commander.args
customArgs: commander.args.slice(0, commander.args.length - 1)
};

buildSolution(config.solutionPath, options);
156 changes: 133 additions & 23 deletions bin/nsc-publish.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,133 @@
// const commander = require('commander');
// const PUBLISH_TYPES = [
// 'Foundation',
// 'Feature',
// 'Projects',
// 'Project',
// 'Assemblies',
// 'Views',
// 'Configs'
// ];
//
// commander
// .usage('[' + PUBLISH_TYPES.join('|') + ']')
// .alias('nsc publish')
// .arguments('<arg1> [arg2]')
// .action((_type_) => {
// options.type = _type_;
// })
// .parse(process.argv);
//
// if (!options.type) {
//
// }
#!/usr/bin/env node

const commander = require('commander');

const config = require('../src/config');
const publish = require('../src/publish');

let publishType = 'all';

commander
.alias('nsc publish')
.usage('<Feature|Foundation|Project|all> [options]')
.option(
'-a, --architecture <arch>',
'Specify the Architecture (Auto-detected, x86, x84)'
)
.option(
'-c, --configuration <config>',
'Specify Build Configuration (Release or Debug)',
/^(Release|Debug)$/
)
.option(
'-t, --targets <targets>',
'Specify Build Targets (Clean,Build,Rebuild)',
(v) => v.split(',')
)
.option(
'-n, --tools-version <version>',
'Specify the .NET Tools-Version (1.0, 1.1, 2.0, 3.5, 4.0, 12.0, 14.0, 15.0, auto)'
)
.option(
'-p, --solution-platform <plateform>',
'Specify the Solution Platform (e.g. x86, x64, Any CPU)'
)
.option(
'-v, --verbosity <level>',
'Specify the amount of information to display in the build output (quiet, minimal, normal, detailed, diagnostic)',
/^(quiet|minimal|normal|detailed|diagnostic)$/
)
.option(
'--nologo',
'Suppress Startup Banner and Copyright Message of MSBuild',
(v) => v + 1
)
.option(
'-m, --maxcpucount <cpuNb>',
'Specify Maximal CPU-Count to use',
parseInt
)
.option(
'-r, --node-reuse <boolean>',
'Specify whether to enable or disable the re-use of MSBuild nodes',
(v) => v === 'false'
)
.option(
'-l, --log-command',
'Logs the msbuild command that will be executed.',
(v) => v + 1
)
.option(
'-d, --dest',
'Directory destination',
(v) => v + 1
)
.action((_publishType_) => {
publishType = _publishType_;
})
.parse(process.argv);

const {
configuration,
targets = config.get('publishTargets'),
maxcpucount = config.get('buildMaxCpuCount'),
verbosity = config.get('buildVerbosity'),
logCommand = config.get('buildLogCommand'),
nodeReuse = config.get('buildNodeReuse'),
toolsVersion = config.get('buildToolsVersion'),
publishPlatform = config.get('publishPlatform'),
publishProperties = config.get('publishProperties'),
nologo,
dest = config.websiteRoot
} = commander;

const options = {
targets,
configuration,
logCommand,
verbosity,
stdout: true,
errorOnFail: true,
maxcpucount,
nodeReuse,
toolsVersion: (+toolsVersion),
nologo,
properties: {
Platform: publishPlatform,
...publishProperties
},
customArgs: commander.args.slice(0, commander.args.length - 1).filter((item) => item !== publishType)
};

let paths;

switch (publishType) {
case 'all':
default:
paths = [
`${config.get('foundationPath')}/**/code/*.csproj`,
`${config.get('featurePath')}/**/code/*.csproj`,
`${config.get('projectPath')}/**/code/*.csproj`
];

break;
case 'Foundation':
paths = [
`${config.get('foundationPath')}/**/code/*.csproj`
];
break;

case 'Feature':
paths = [
`${config.get('featurePath')}/**/code/*.csproj`
];
break;

case 'Project':
paths = [
`${config.get('featurePath')}/**/code/*.csproj`
];
break;
}

publish(paths, dest, options);
1 change: 1 addition & 0 deletions bin/nsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ commander
.command('restore', 'Restore all NuGet Packages')
// .command('install', 'Install a sitecore package')
.command('build', 'Build project solution')
.command('publish', 'Publish project solution')
.command('unicorn [action] [configs ...]', 'Perform a Unicorn synchronisation')
.command('publish', 'Publish content (Foundation, Feature, Project)')
.command('proxy-server', 'Run a proxy server')
Expand Down
Loading

0 comments on commit 7b4422e

Please sign in to comment.