Skip to content

Commit

Permalink
Merge pull request #22 from cix-cdx/dev
Browse files Browse the repository at this point in the history
 RELEASE: v.2.1.0-alpha.1
  • Loading branch information
tpanitte committed Jun 1, 2018
2 parents cf51ffd + 8a224a3 commit 6830501
Show file tree
Hide file tree
Showing 34 changed files with 3,537 additions and 40 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
node_modules/

# Files
package-lock.json
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Folders
.nyc_output/
test/
scripts/

# Files
.gitignore
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This **cix-lic** modules can license a project via several capabilities.

- **CLI** - Command Line
- **CI** - Continuous Integration
- **API** - Application Program Interface

#### LIC Properties

Expand All @@ -21,13 +22,17 @@ Before we use **cix-lic**, it's important to know what properties are used. It's

- **endYear** | **-e** - the **declarative end year** - _default: "Present"_

- **proc** | **-p** - the **process** - _default: ["lic", "file"]_

- **baseDir** | **-d** - the **directory** where to query files - _default: root source directory_

- **filter** | **-f** - the **file filter** can be **string**, **RegExp**, or **{ test: () => _boolean_ }** - _default: *.js_

- **licFile** | **-i** - the specfied **lic file** (file header) - _default: undefined_
- **HFLcontent** | **-h** - the **Head File License Content** (file header content) - _default: undefined_

- **licenseContent** | **-c** - the **License Content** (license content) - _default: undefined_

- **licenseFile** | **-c** - the specfied **license file** (package) - _default: undefined_
- **licenseFile** - the **License File** (license file) - _default: ./LICENSE_

### CLI - Command Line

Expand Down Expand Up @@ -69,11 +74,10 @@ Then, we can run **cix-lic** script in **CI Process**.

### CIX-LIC Command

**Command Tags** are [**LIC Properties**](#lic-properties) and two tags, **conf** and **proc**.
**Command Tags** are [**LIC Properties**](#lic-properties)

**Examples**

cix-lic -o Jane Smith -l mit >> _owner_: **Jane Smith**, _lic_: **MIT License**

cix-lic -l apache-2.0 -d ./lib >> _lic_: **Apache License 2.0**, _baseDir_: **./lib**
cix-lic **-o** _Jane Smith_ **-l** _mit_ >> **owner**: _Jane Smith_, **lic**: _MIT License_

cix-lic **-d** _./lib_ **-l** _apache-2.0_ >> **baseDir**: _./lib_, **lic**: _Apache License 2.0_
4 changes: 0 additions & 4 deletions cix-lic.json

This file was deleted.

61 changes: 55 additions & 6 deletions lib/cli.js → cli.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env node

const Chalk = require('chalk');
const ArgvLoader = require('./core/argv.loader');
const ConfigLoader = require('./core/config.loader');
const LICPropsBuilder = require('./licprops.builder');
const LicenseProcess = require('./license.process');
const HFLicenseProcess = require('./HFLicense.process');
const ArgvLoader = require('./lib/core/argv.loader');
const ConfigLoader = require('./lib/core/config.loader');
const LICPropsBuilder = require('./lib/licprops.builder');
const LicenseProcess = require('./lib/license.process');
const HFLicenseProcess = require('./lib/HFLicense.process');

const argv = ArgvLoader.load();
const props = argv.hasOwnProperty('conf') ? ConfigLoader.load(argv.conf, argv) : argv;
Expand Down Expand Up @@ -80,14 +82,54 @@ const LicensingProcess = {
} else {
console.log(Chalk.yellow('\n - HFLicensing Process : Skipped!\n'));
}
}
};

const UnlicensingProcess = {
LicenseProcess: () => {
console.log(Chalk.cyan('# UNLICENSING PROCESS : Processing..'));

if (LICProps.proc.indexOf('lic') > -1) {
if (LicenseProcess.unlicensing(LICProps)) {
console.log(Chalk.green('\n License File REMOVED..\n'));
} else {
console.log('\n - License File NOT EXIST..\n');
}
} else {
console.log(Chalk.yellow('\n - Unlicensing Process : Skipped!\n'));
}
},
HFLProcess: () => {
console.log(Chalk.cyan('# UNHFLICENSING PROCESS : Processing..'));

console.log('\n - Process Completed\n');
if (LICProps.proc.indexOf('file') > -1) {
const handler = (error, negative, positive) => {
if (negative) {
console.log(` ${negative} - NOT EXIST..`);
} else if (positive) {
console.log(` ${positive} - ${Chalk.green('REMOVED..')} `);
}
};

HFLicenseProcess.unlicensing(LICProps, handler);
} else {
console.log(Chalk.yellow('\n - UnHFLicensing Process : Skipped!\n'));
}
}
};

const outProps = (_licprops, _props) => console.log(`${Chalk.green('#LIC Properties')}
license: ${Chalk.yellow(_licprops.license)}
owner: ${Chalk.green(_licprops.owner)}
beginYear: ${Chalk.green(_licprops.beginYear)}
endYear: ${Chalk.green(_licprops.endYear)}
baseDir: ${Chalk.green(_props.baseDir)}
`);

// :: CLI Process ::

console.log(`\n:: ${Chalk.cyan('CIX-LIC')} ::\n`);
outProps(LICProps, props);

if (LICProps.assert) {
console.log(Chalk.yellow(':: ASSERT MODE ::\n'));
Expand All @@ -96,6 +138,13 @@ if (LICProps.assert) {
console.log();
AssertingProcess.HFLProcess();

} else if (LICProps.unlicense) {
console.log(Chalk.yellow(':: UNLICENSE MODE ::\n'));

UnlicensingProcess.LicenseProcess();
console.log();
UnlicensingProcess.HFLProcess();

} else {
console.log(Chalk.yellow(':: PROCESS MODE ::\n'));

Expand Down
11 changes: 11 additions & 0 deletions lib/HFLicense.process.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const HFLicensor = require('./licensors/HFLicensor');

const HFLicenseProcess = {
assert: (LICProps, callback) => HFLicensor.assert(LICProps.HFLcontent, LICProps.HFLqueries, callback, LICProps.assertAll),
licensing: (LICProps, callback) => HFLicensor.process(LICProps.HFLcontent, LICProps.HFLqueries, callback),
unlicensing: (LICProps, callback) => HFLicensor.unlicense(LICProps.HFLcontent, LICProps.HFLqueries, callback),
};

module.exports = HFLicenseProcess;
14 changes: 14 additions & 0 deletions lib/core/argv.loader.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const AppEnv = require('archappenv').AppEnv;

const ArgvLoader = {
Expand Down Expand Up @@ -61,6 +71,10 @@ const ArgvLoader = {
}
}

if (v.hasOwnProperty('unlicense')) {
props.unlicense = true;
}

return props;
}
};
Expand Down
24 changes: 21 additions & 3 deletions lib/core/config.loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const AppEnv = require('archappenv').AppEnv;
const FS = require('fs');

const ConfigLoader = {
load: (file = './cix-lic.json', argv = {}) => {
const configFile = AppEnv.Util.resolveFile(file);
load: (file, argv = {}) => {
const _file = file || './cix-lic.json';
const configFile = AppEnv.Util.resolveFile(_file);
let config;

if (FS.existsSync(configFile)) {
const config = require(configFile);
config = require(configFile);
} else if (!file) {
const pkgJSONFile = AppEnv.Util.packageJSON();
const pkgJSON = require(pkgJSONFile);
config = pkgJSON['cix-lic'];
}

if (config) {
if (argv.assert) {
config.assert = argv.assert;
}
Expand Down
20 changes: 19 additions & 1 deletion lib/core/files.resolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const AppEnv = require('archappenv').AppEnv;
const FS = require('fs');
const Path = require('path');
Expand All @@ -6,7 +16,15 @@ const DefaultFilter = /\.js$/;

const FilesResolver = {
resolve: (baseDir, filter) => {
const resolved = AppEnv.Util.resolvePath(baseDir);
let resolved;

if (Path.isAbsolute(baseDir)) {
resolved = baseDir;
} else {
const mainpkg = AppEnv.Services.mainPackagepath();
resolved = Path.join(mainpkg, baseDir);
}

const subpaths = AppEnv.Util.subpathsSync(resolved);
const Filter = FilesResolver.toFilter(filter);

Expand Down
10 changes: 10 additions & 0 deletions lib/core/license.map.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const LicenseName = require('../data/common/license.name.json');
const HeadFileLicense = require('../data/headfile.license');
const License = require('../data/license');
Expand Down
10 changes: 10 additions & 0 deletions lib/data/headfile.license.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = (LICProps) =>
`/*
* Copyright (c) ${LICProps.beginYear} - ${LICProps.endYear.toLowerCase()}, ${LICProps.owner}. All Rights Reserved.
Expand Down
10 changes: 10 additions & 0 deletions lib/data/license.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


const License = (LICProps) => {
const lic = LICProps.lic;
const file = `./licenses/${lic.toLowerCase()}.js`;
Expand Down
10 changes: 10 additions & 0 deletions lib/data/licenses/apache-1.0.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = () =>
`/* ====================================================================
* Copyright (c) 1995-1999 The Apache Group. All rights reserved.
Expand Down
10 changes: 10 additions & 0 deletions lib/data/licenses/apache-1.1.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = () =>
`/* ====================================================================
* The Apache Software License, Version 1.1
Expand Down
10 changes: 10 additions & 0 deletions lib/data/licenses/apache-2.0.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = () =>
` Apache License
Version 2.0, January 2004
Expand Down
10 changes: 10 additions & 0 deletions lib/data/licenses/mit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = (LICProps) =>
`The MIT License
Expand Down
12 changes: 11 additions & 1 deletion lib/data/licenses/nolicenses.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = (LICProps) =>
`Software is an intellectual property
`Software is the Intellectual Property
A copy of license not provided, please contact the owner: ${LICProps.owner} before use this software
`;
10 changes: 10 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright (c) 2018 - present, Architecode Corporation. All Rights Reserved.
*
* This source code is licensed under the MIT License.
* The LICENSE file can be found in the root directory.
*
* @cix-lic
*/


module.exports = {
CIXLIC: {
HFLicenseProcess: require('./HFLicense.process'),
Expand Down

0 comments on commit 6830501

Please sign in to comment.