@konomi-app/k2 0.1.4 β 0.2.0
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/dist/commands/build-base.js +4 -29
- package/dist/commands/build.js +36 -0
- package/dist/commands/plugin-build.js +6 -6
- package/dist/commands/plugin-dev.js +1 -0
- package/dist/commands/vite-build.js +30 -0
- package/dist/commands/{vite-dev/index.js β vite-dev.js} +3 -3
- package/dist/index.js +2 -4
- package/dist/lib/webpack.js +4 -28
- package/package.json +9 -9
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
6
|
-
export default function command() {
|
|
7
|
-
program
|
|
8
|
-
.command('build')
|
|
9
|
-
.description("Build the project for production. (It's a wrapper of Vite build command.)")
|
|
10
|
-
.action(action);
|
|
11
|
-
}
|
|
12
|
-
export async function action() {
|
|
13
|
-
console.group('π³ Build the project for production');
|
|
14
|
-
try {
|
|
15
|
-
const config = await importPluginConfig();
|
|
16
|
-
const viteConfig = getViteConfig(config);
|
|
17
|
-
await build({
|
|
18
|
-
...viteConfig,
|
|
19
|
-
mode: 'production',
|
|
20
|
-
build: { ...viteConfig.build, outDir: PLUGIN_CONTENTS_DIRECTORY },
|
|
21
|
-
});
|
|
22
|
-
console.log('β¨ Build success.');
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
console.groupEnd();
|
|
29
|
-
}
|
|
1
|
+
import { buildWithWebpack } from '../lib/webpack.js';
|
|
2
|
+
export default async function action(params) {
|
|
3
|
+
const { entries, outDir } = params;
|
|
4
|
+
return buildWithWebpack({ entries, outDir });
|
|
30
5
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { WORKSPACE_DIRECTORY } from '../lib/constants.js';
|
|
5
|
+
import base from './build-base.js';
|
|
6
|
+
export default function command() {
|
|
7
|
+
program
|
|
8
|
+
.command('build')
|
|
9
|
+
.option('-o, --outdir <outdir>', 'Output directory.', path.join(WORKSPACE_DIRECTORY, 'prod'))
|
|
10
|
+
.option('-i, --input <input>', 'Input directory.', path.join('src', 'apps'))
|
|
11
|
+
.description("Build the project for production. (It's a wrapper of webpack build command.)")
|
|
12
|
+
.action(action);
|
|
13
|
+
}
|
|
14
|
+
export async function action(options) {
|
|
15
|
+
console.group('π³ Build the project for production');
|
|
16
|
+
try {
|
|
17
|
+
const { outdir, input } = options;
|
|
18
|
+
const allProjects = fs.readdirSync(path.resolve(input));
|
|
19
|
+
const entries = allProjects.reduce((acc, dir) => {
|
|
20
|
+
for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
|
|
21
|
+
if (fs.existsSync(path.join(input, dir, filename))) {
|
|
22
|
+
return { ...acc, [dir]: path.join(input, dir, filename) };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return acc;
|
|
26
|
+
}, {});
|
|
27
|
+
await base({ entries, outDir: outdir });
|
|
28
|
+
console.log('β¨ Build success.');
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
console.groupEnd();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { program } from 'commander';
|
|
2
2
|
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
3
|
-
import { buildWithWebpack } from '../lib/webpack.js';
|
|
4
3
|
import path from 'path';
|
|
4
|
+
import base from './build-base.js';
|
|
5
5
|
export default function command() {
|
|
6
6
|
program
|
|
7
7
|
.command('build')
|
|
@@ -11,11 +11,11 @@ export default function command() {
|
|
|
11
11
|
export async function action() {
|
|
12
12
|
console.group('π³ Build the project for production');
|
|
13
13
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
14
|
+
const entries = {
|
|
15
|
+
desktop: path.join('src', 'desktop', 'index.ts'),
|
|
16
|
+
config: path.join('src', 'config', 'index.ts'),
|
|
17
|
+
};
|
|
18
|
+
await base({ entries, outDir: PLUGIN_CONTENTS_DIRECTORY });
|
|
19
19
|
console.log('β¨ Build success.');
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
@@ -70,6 +70,7 @@ export async function action() {
|
|
|
70
70
|
uploadZip('dev').then(({ stdout, stderr }) => {
|
|
71
71
|
console.log(stdout);
|
|
72
72
|
console.error(stderr);
|
|
73
|
+
console.log('π€ Plugin uploaded');
|
|
73
74
|
});
|
|
74
75
|
const entryPoints = ['desktop', 'config'].map((dir) => ({
|
|
75
76
|
in: path.join('src', dir, 'index.ts'),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { program } from 'commander';
|
|
2
|
+
import { build } from 'vite';
|
|
3
|
+
import { importPluginConfig } from '../lib/import.js';
|
|
4
|
+
import { getViteConfig } from '../lib/vite.js';
|
|
5
|
+
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
6
|
+
export default function command() {
|
|
7
|
+
program
|
|
8
|
+
.command('build')
|
|
9
|
+
.description("Build the project for production. (It's a wrapper of Vite build command.)")
|
|
10
|
+
.action(action);
|
|
11
|
+
}
|
|
12
|
+
export async function action() {
|
|
13
|
+
console.group('π³ Build the project for production');
|
|
14
|
+
try {
|
|
15
|
+
const config = await importPluginConfig();
|
|
16
|
+
const viteConfig = getViteConfig(config);
|
|
17
|
+
await build({
|
|
18
|
+
...viteConfig,
|
|
19
|
+
mode: 'production',
|
|
20
|
+
build: { ...viteConfig.build, outDir: PLUGIN_CONTENTS_DIRECTORY },
|
|
21
|
+
});
|
|
22
|
+
console.log('β¨ Build success.');
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
console.groupEnd();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { program } from 'commander';
|
|
2
2
|
import { createServer, build } from 'vite';
|
|
3
|
-
import { importPluginConfig } from '
|
|
4
|
-
import { getViteConfig } from '
|
|
3
|
+
import { importPluginConfig } from '../lib/import.js';
|
|
4
|
+
import { getViteConfig } from '../lib/vite.js';
|
|
5
5
|
import chokidar from 'chokidar';
|
|
6
|
-
import { PLUGIN_DEVELOPMENT_DIRECTORY } from '
|
|
6
|
+
import { PLUGIN_DEVELOPMENT_DIRECTORY } from '../lib/constants.js';
|
|
7
7
|
export default function command() {
|
|
8
8
|
program.command('dev').description('Start development server.').action(action);
|
|
9
9
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from 'commander';
|
|
3
|
-
import build from './commands/build
|
|
3
|
+
import build from './commands/build.js';
|
|
4
4
|
import dev from './commands/dev.js';
|
|
5
5
|
import genkey from './commands/genkey.js';
|
|
6
|
-
|
|
7
|
-
program.name('k2').version('0.1.0').description('');
|
|
6
|
+
program.name('k2').version('0.1.0').description('k2 - π³ kintone kitchen π³');
|
|
8
7
|
build();
|
|
9
8
|
dev();
|
|
10
9
|
genkey();
|
|
11
|
-
upload();
|
|
12
10
|
program.parse(process.argv);
|
package/dist/lib/webpack.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from 'fs';
|
|
2
1
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import { cwd } from 'process';
|
|
@@ -7,34 +6,14 @@ import webpack from 'webpack';
|
|
|
7
6
|
import chalk from 'chalk';
|
|
8
7
|
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
|
|
9
8
|
export const buildWithWebpack = async (props) => {
|
|
10
|
-
const {
|
|
11
|
-
/** @type { Record<string, string> } */
|
|
12
|
-
let entry = {};
|
|
13
|
-
if (mode === 'app') {
|
|
14
|
-
const appsRoot = path.join(srcRoot, 'apps');
|
|
15
|
-
const allProjects = readdirSync(appsRoot);
|
|
16
|
-
entry = allProjects.reduce((acc, dir) => {
|
|
17
|
-
for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
|
|
18
|
-
if (existsSync(path.join(appsRoot, dir, filename))) {
|
|
19
|
-
return { ...acc, [dir]: path.join(appsRoot, dir, filename) };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return acc;
|
|
23
|
-
}, {});
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
entry = {
|
|
27
|
-
desktop: path.join(srcRoot, 'desktop', 'index.ts'),
|
|
28
|
-
config: path.join(srcRoot, 'config', 'index.ts'),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
9
|
+
const { entries, outDir } = props;
|
|
31
10
|
const exclude = /node_modules/;
|
|
32
11
|
const styleLoader = MiniCssExtractPlugin.loader;
|
|
33
12
|
return new Promise((resolve, reject) => {
|
|
34
13
|
webpack({
|
|
35
14
|
mode: 'production',
|
|
36
15
|
target: ['web', 'es2023'],
|
|
37
|
-
entry,
|
|
16
|
+
entry: entries,
|
|
38
17
|
resolve: {
|
|
39
18
|
extensions: ['.ts', '.tsx', '.js', '.json'],
|
|
40
19
|
fallback: {
|
|
@@ -43,10 +22,7 @@ export const buildWithWebpack = async (props) => {
|
|
|
43
22
|
plugins: [new TsconfigPathsPlugin({ configFile: path.join(cwd(), 'tsconfig.json') })],
|
|
44
23
|
},
|
|
45
24
|
cache: { type: 'filesystem' },
|
|
46
|
-
output: {
|
|
47
|
-
filename: '[name].js',
|
|
48
|
-
path: path.resolve(cwd(), ...distRoot.split(/[\\\/]/g)),
|
|
49
|
-
},
|
|
25
|
+
output: { filename: '[name].js', path: outDir },
|
|
50
26
|
module: {
|
|
51
27
|
rules: [
|
|
52
28
|
{ test: /\.tsx?$/, exclude, loader: 'ts-loader' },
|
|
@@ -73,7 +49,7 @@ export const buildWithWebpack = async (props) => {
|
|
|
73
49
|
else {
|
|
74
50
|
if (stats?.compilation.errors.length) {
|
|
75
51
|
reject([
|
|
76
|
-
chalk.red('β
|
|
52
|
+
chalk.red('β Build failed.'),
|
|
77
53
|
...stats.compilation.errors.map((error) => error.message),
|
|
78
54
|
].join('\n'));
|
|
79
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomi-app/k2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "kintone sdk",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"express": "^4",
|
|
37
37
|
"fs-extra": "^11",
|
|
38
38
|
"html-minifier": "^4",
|
|
39
|
-
"mini-css-extract-plugin": "^2
|
|
39
|
+
"mini-css-extract-plugin": "^2",
|
|
40
40
|
"sass": "^1",
|
|
41
|
-
"sass-loader": "^14
|
|
42
|
-
"style-loader": "^4
|
|
43
|
-
"terser-webpack-plugin": "^5
|
|
44
|
-
"ts-loader": "^9
|
|
45
|
-
"tsconfig-paths-webpack-plugin": "^4
|
|
41
|
+
"sass-loader": "^14",
|
|
42
|
+
"style-loader": "^4",
|
|
43
|
+
"terser-webpack-plugin": "^5",
|
|
44
|
+
"ts-loader": "^9",
|
|
45
|
+
"tsconfig-paths-webpack-plugin": "^4",
|
|
46
46
|
"vite": "^5",
|
|
47
47
|
"vite-tsconfig-paths": "^4",
|
|
48
|
-
"webpack": "^5
|
|
48
|
+
"webpack": "^5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/archiver": "*",
|
|
52
|
-
"@types/express": "^4
|
|
52
|
+
"@types/express": "^4",
|
|
53
53
|
"@types/fs-extra": "*",
|
|
54
54
|
"@types/html-minifier": "^4",
|
|
55
55
|
"typescript": "*"
|