@ossy/cli 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -16
- package/package.json +4 -3
- package/src/index.js +0 -1
- package/src/app/build.js +0 -95
- package/src/app/cli.js +0 -22
package/README.md
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
# @ossy/cli
|
|
2
2
|
|
|
3
|
-
Command line tool that makes it easier to interact with our
|
|
4
|
-
|
|
5
|
-
## App
|
|
6
|
-
|
|
7
|
-
### build
|
|
8
|
-
|
|
9
|
-
Builds a production version of the app
|
|
10
|
-
```
|
|
11
|
-
npx @ossy/cli app build
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
### serve
|
|
15
|
-
Serves the app
|
|
16
|
-
```
|
|
17
|
-
npx @ossy/cli app serve
|
|
18
|
-
```
|
|
3
|
+
Command line tool that makes it easier to interact with our APIs
|
|
19
4
|
|
|
20
5
|
## Cms
|
|
21
6
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"repository": "github:ossy-se/packages",
|
|
4
5
|
"description": "Command line tool that makes it easier to interact with our APIs",
|
|
5
6
|
"source": "./src/index.js",
|
|
6
7
|
"main": "./src/index.js",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"scripts": {
|
|
9
|
-
"test": "echo \"Error: no test specified\" && exit
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
10
11
|
"build": "echo \"The build step is not required when using JavaScript!\" && exit 0"
|
|
11
12
|
},
|
|
12
13
|
"author": "Ossy",
|
|
13
|
-
"license": "
|
|
14
|
+
"license": "MIT License",
|
|
14
15
|
"bin": "./src/index.js",
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"arg": "^5.0.2",
|
package/src/index.js
CHANGED
package/src/app/build.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { rollup } from 'rollup';
|
|
4
|
-
import babel from '@rollup/plugin-babel';
|
|
5
|
-
import { nodeResolve as resolveDependencies } from '@rollup/plugin-node-resolve'
|
|
6
|
-
import resolveCommonJsDependencies from '@rollup/plugin-commonjs'
|
|
7
|
-
import removeOwnPeerDependencies from 'rollup-plugin-peer-deps-external'
|
|
8
|
-
import minifyJS from '@rollup/plugin-terser'
|
|
9
|
-
// import typescript from '@rollup/plugin-typescript'
|
|
10
|
-
import preserveDirectives from "rollup-plugin-preserve-directives"
|
|
11
|
-
import json from "@rollup/plugin-json"
|
|
12
|
-
import copy from 'rollup-plugin-copy';
|
|
13
|
-
import replace from '@rollup/plugin-replace';
|
|
14
|
-
import remove from 'rollup-plugin-delete';
|
|
15
|
-
|
|
16
|
-
// export const build = async ({
|
|
17
|
-
// source = 'src/index.jsx',
|
|
18
|
-
// destination = 'build',
|
|
19
|
-
// }) => {
|
|
20
|
-
// console.log('[@ossy/app][Build] Starting build...')
|
|
21
|
-
|
|
22
|
-
// const sourcePath = path.resolve(source);
|
|
23
|
-
// const destinationDir = path.resolve(destination);
|
|
24
|
-
|
|
25
|
-
// if (!fs.existsSync(sourcePath)) {
|
|
26
|
-
// throw new Error(`[@ossy/app][Build] Source path does not exist: ${sourcePath}`);
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
// const sourceData = fs.readFileSync(sourcePath, 'utf8');
|
|
30
|
-
|
|
31
|
-
// fs.mkdirSync(destinationDir, { recursive: true });
|
|
32
|
-
// fs.writeFileSync(path.join(destinationDir, 'index.js'), sourceData, { encoding: 'utf8', flag: 'w' });
|
|
33
|
-
|
|
34
|
-
// console.log('[@ossy/app][Build] Build finished')
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Build folder structure
|
|
40
|
-
// build/server.js (provided by script)
|
|
41
|
-
// build/pages.js (manifest of pages and their entry points)
|
|
42
|
-
// build/<page-id>.page.js (for each page)
|
|
43
|
-
// build/static/index.js
|
|
44
|
-
// build/static/*.js
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export const build = async ({
|
|
48
|
-
source = 'src/App.jsx',
|
|
49
|
-
destination = 'build',
|
|
50
|
-
} = {}) => {
|
|
51
|
-
console.log('[@ossy/cli][app][build] Starting...')
|
|
52
|
-
|
|
53
|
-
const sourcePath = path.resolve(source);
|
|
54
|
-
const buildPath = path.resolve(destination);
|
|
55
|
-
|
|
56
|
-
if (!fs.existsSync(sourcePath)) {
|
|
57
|
-
throw new Error(`[@ossy/cli][app][build] Source path does not exist: ${sourcePath}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const inputOptions = {
|
|
61
|
-
input: sourcePath,
|
|
62
|
-
plugins: [
|
|
63
|
-
remove({ targets: buildPath }),
|
|
64
|
-
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
|
|
65
|
-
json(),
|
|
66
|
-
removeOwnPeerDependencies(),
|
|
67
|
-
resolveCommonJsDependencies(),
|
|
68
|
-
resolveDependencies({ preferBuiltins: true }),
|
|
69
|
-
babel({
|
|
70
|
-
babelHelpers: 'bundled',
|
|
71
|
-
exclude: ['**/node_modules/**/*'],
|
|
72
|
-
presets: ['@babel/preset-env', '@babel/preset-react']
|
|
73
|
-
}),
|
|
74
|
-
preserveDirectives(),
|
|
75
|
-
minifyJS(),
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const outputOptions = [
|
|
80
|
-
{
|
|
81
|
-
dir: 'build',
|
|
82
|
-
entryFileNames: ({ name }) => name === 'server' ? '[name].js' : 'static/[name].js',
|
|
83
|
-
chunkFileNames: 'static/[name]-[hash].js',
|
|
84
|
-
format: 'esm',
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
const bundle = await rollup(inputOptions);
|
|
89
|
-
|
|
90
|
-
for (const options of outputOptions) {
|
|
91
|
-
await bundle.write(options);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
console.log('[@ossy/cli][app][build] Finished');
|
|
95
|
-
};
|
package/src/app/cli.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const [_, __, handlerName, ...restArgs] = process.argv
|
|
4
|
-
import { build } from './cli/build.js'
|
|
5
|
-
|
|
6
|
-
export const handler = ([command, ...options]) => {
|
|
7
|
-
|
|
8
|
-
if (!command) {
|
|
9
|
-
logError({ message: '[@ossy/cli][app] No command provided' })
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const commandHandler = {
|
|
13
|
-
'build': build,
|
|
14
|
-
}[command]
|
|
15
|
-
|
|
16
|
-
if (!commandHandler) {
|
|
17
|
-
logError({ message: `[@ossy/cli][app] Unknown command: ${command}` })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
commandHandler(options)
|
|
21
|
-
|
|
22
|
-
}
|