Skip to content

Commit

Permalink
new build and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
nicmosc committed Jul 8, 2019
1 parent 05ff000 commit 120e04e
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 274 deletions.
2 changes: 1 addition & 1 deletion bin/louki
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var conf = {};
var appCfg = require('rc')('louki', conf);

program
.version('0.0.1')
.version('1.0.0')
.arguments('<cmd> [options]')
.action(function (cmd, options) {
cmdValue = cmd ;
Expand Down
25 changes: 25 additions & 0 deletions dist/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = build;

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

var _utils = require('./utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function build(rootFolder, targetPath, locale) {
var finalTranslation = (0, _utils.fromFolders)(rootFolder, locale);
try {
_fs2.default.writeFileSync(targetPath + '/' + locale + '.yml', finalTranslation); // file type is hardcoded for now
console.log('Updated target file ' + locale + '.yml');
} catch (err) {
console.error(err);
}
return finalTranslation;
}
39 changes: 12 additions & 27 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,41 @@ var _nodeWatch = require('node-watch');

var _nodeWatch2 = _interopRequireDefault(_nodeWatch);

var _pull = require('./pull');

var _pull2 = _interopRequireDefault(_pull);

var _push = require('./push');

var _push2 = _interopRequireDefault(_push);

var _update = require('./update');

var _update2 = _interopRequireDefault(_update);

var _init = require('./init');
var _build = require('./build');

var _init2 = _interopRequireDefault(_init);
var _build2 = _interopRequireDefault(_build);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
AVAILABLE COMMANDS:
- update : will parse the translations from the root folder provided and replae
- build : will parse the translations from the root folder provided and replace
the contents of dist with the new translation (only the default local will be replaced)
- push : will call update and then through localeapp it will push the final yml file (default local only again)
- pull : will retrieve the data from localeapp and replace the contents of dist with those files, it will
also disect the large translation file (en.yml) and replace the contents of the index files.
- update : will disect the large translation file ([default].yml) and replace the contents of the index files
**/

function louki(command, rootFolder, targetPath, option, extra) {
var pushDefault = extra.pushDefault,
watchFiles = extra.watchFiles,
raw = extra.raw;
function louki(command, rootFolder, targetPath, option) {
var extra = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var watchFiles = extra.watchFiles;

var defaultLocale = option;
if (command === 'init') {
(0, _init2.default)(option);
} else if (command === 'update') {
if (command === 'build') {
if (watchFiles) {
console.log('Louki watching for changes in root folder...');
(0, _update2.default)(rootFolder, targetPath, defaultLocale); // run once
(0, _nodeWatch2.default)(rootFolder, { recursive: true, filter: /\.(json|yml)$/ }, function (evt, fileName) {
console.log(evt, fileName.replace(rootFolder, ''));
return (0, _update2.default)(rootFolder, targetPath, defaultLocale);
return (0, _build2.default)(rootFolder, targetPath, defaultLocale);
});
} else {
return (0, _update2.default)(rootFolder, targetPath, defaultLocale);
return (0, _build2.default)(rootFolder, targetPath, defaultLocale);
}
} else if (command === 'push') {
return (0, _push2.default)(rootFolder, targetPath, defaultLocale, pushDefault, raw);
} else if (command === 'pull') {
return (0, _pull2.default)(rootFolder, targetPath, defaultLocale, raw);
} else if (command === 'update') {
return (0, _update2.default)(rootFolder, targetPath, defaultLocale);
} else {
console.error('Command not found');
return;
Expand Down
55 changes: 0 additions & 55 deletions dist/init.js

This file was deleted.

54 changes: 0 additions & 54 deletions dist/pull.js

This file was deleted.

51 changes: 0 additions & 51 deletions dist/push.js

This file was deleted.

8 changes: 4 additions & 4 deletions dist/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function update(rootFolder, targetPath, locale) {
var finalTranslation = (0, _utils.fromFolders)(rootFolder, locale);
try {
_fs2.default.writeFileSync(targetPath + '/' + locale + '.yml', finalTranslation); // file type is hardcoded for now
console.log('Updated target file ' + locale + '.yml');
var compiledLocale = _fs2.default.readFileSync(targetPath + '/' + locale + '.yml', 'utf8');
var updatedFolders = (0, _utils.toFolders)(rootFolder, compiledLocale, locale);
console.log('Folders updated');
return updatedFolders;
} catch (err) {
console.error(err);
}
return finalTranslation;
}
38 changes: 0 additions & 38 deletions dist/utils/api.js

This file was deleted.

44 changes: 1 addition & 43 deletions dist/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.toFolders = exports.fromFolders = undefined;

var _api = require('./api');

Object.keys(_api).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _api[key];
}
});
});

var _conversion = require('./conversion');

Object.keys(_conversion).forEach(function (key) {
Expand All @@ -28,16 +16,6 @@ Object.keys(_conversion).forEach(function (key) {
}
});
});
exports.getConfigPath = getConfigPath;
exports.getProjectName = getProjectName;

var _fs = require('fs');

var _fs2 = _interopRequireDefault(_fs);

var _path = require('path');

var _path2 = _interopRequireDefault(_path);

var _fromFolders2 = require('./from-folders');

Expand All @@ -50,24 +28,4 @@ var _toFolders3 = _interopRequireDefault(_toFolders2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.fromFolders = _fromFolders3.default;
exports.toFolders = _toFolders3.default;
function getConfigPath() {
var create = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

var home = require('user-home');
var directory = home + '/.louki';
if (!_fs2.default.existsSync(directory) && create) {
_fs2.default.mkdirSync(directory);
}
return directory + '/config.json';
}

function getProjectName() {
var pathToPackage = _path2.default.resolve('package.json');
var name = JSON.parse(_fs2.default.readFileSync(pathToPackage, 'utf8')).name;
if (!name) {
console.log('Missing required "name" in package.json');
process.exit();
}
return name;
}
exports.toFolders = _toFolders3.default;
Loading

0 comments on commit 120e04e

Please sign in to comment.