Skip to content

Commit

Permalink
feat: 🎸 Added package @ima/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimck committed Jun 4, 2021
1 parent 7bc7d68 commit 35e3b5f
Show file tree
Hide file tree
Showing 10 changed files with 856 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@ module.exports = {
extend: true,
chrome: true,
FB: true
}
},
overrides: [
{
files: ['packages/cli/**', 'packages/create-ima-app/**'],
rules: {
'no-console': 'off'
}
}
]
};
Empty file added packages/cli/.eslintrc.js
Empty file.
11 changes: 11 additions & 0 deletions packages/cli/bin/ima.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node

const path = require('path');

require('yargs')
.scriptName('ima')
.usage('Usage: $0 <command>')
.commandDir(path.resolve(__dirname, '../scripts'))
.demandCommand(1, 'You need to run at least one command to move on')
.help()
.wrap(null).argv;
687 changes: 687 additions & 0 deletions packages/cli/package-lock.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@ima/cli",
"version": "17.10.0",
"description": "IMA.js CLI tool to build, develop and work with IMA.js applications.",
"keywords": [
"IMA",
"IMA.js",
"Isomorphic",
"Javascript"
],
"bin": {
"ima": "./bin/ima.js"
},
"author": "Miroslav Jancarik <miroslav.jancarik@firma.seznam.cz>",
"contributors": [],
"repository": {
"type": "git",
"url": "https://github.com/seznam/ima.git"
},
"bugs": {
"url": "https://github.com/seznam/ima/issues"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"license": "MIT",
"devDependencies": {
"chalk": "^4.1.1",
"yargs": "^17.0.1"
},
"dependencies": {
"webpack": "^5.38.1"
}
}
45 changes: 45 additions & 0 deletions packages/cli/scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('path');
const webpack = require('webpack');

async function build(args) {
const compiler = webpack({
mode: 'production',
entry: path.resolve(args.cwd, 'test/index.js')
});

compiler.run((err, stats) => {
if (!err) {
const out = stats.toString({
assets: true,
cached: false,
children: false,
chunks: false,
chunkModules: false,
colors: true,
hash: true,
modules: false,
reasons: false,
source: false,
timings: true,
version: true
});

console.log(out);
} else {
console.error(err);
}
});
}

const buildCommand = {
command: 'build',
desc: 'Build an application for production',
handler: async yargs => {
await build({
yargs: yargs,
cwd: process.cwd()
});
}
};

module.exports = buildCommand;
50 changes: 50 additions & 0 deletions packages/cli/scripts/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const path = require('path');
const webpack = require('webpack');

async function dev(args) {
const compiler = webpack({
mode: 'production',
entry: path.resolve(args.cwd, 'test/index.js')
});

compiler.watch({}, (err, stats) => {
if (!err) {
const out = stats.toString({
assets: true,
cached: false,
children: false,
chunks: false,
chunkModules: false,
colors: true,
hash: true,
modules: false,
reasons: false,
source: false,
timings: true,
version: true
});

console.log(out);
} else {
console.error(err);
}
});
}

const devCommand = {
command: 'dev',
desc: 'Run application in development mode',
builder: {
'legacy-compat-mode': {
desc: 'Runs application in ES5 compatible format'
}
},
handler: async yargs => {
await dev({
yargs: yargs,
cwd: process.cwd()
});
}
};

module.exports = devCommand;
14 changes: 14 additions & 0 deletions packages/cli/scripts/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const start = {
command: 'start',
desc: 'Run application in production',
builder: {
'legacy-compat-mode': {
desc: 'Runs application in ES5 compatible format'
}
},
handler: yargs => {
console.log(yargs);
}
};

module.exports = start;
5 changes: 5 additions & 0 deletions packages/cli/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function test() {
console.log('Hi!');
}

module.exports = { test };
Empty file added packages/cli/webpack.config.js
Empty file.

0 comments on commit 35e3b5f

Please sign in to comment.