@konomi-app/k2 1.7.7 → 1.8.2

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.
@@ -1,3 +1,4 @@
1
+ import {} from 'webpack';
1
2
  import { buildWithWebpack } from '../lib/webpack.js';
2
3
  export default async function action(params) {
3
4
  const { entries, outDir } = params;
@@ -2,6 +2,7 @@ import { program } from 'commander';
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
4
  import { WORKSPACE_DIRECTORY } from '../lib/constants.js';
5
+ import {} from 'esbuild';
5
6
  import { buildWithEsbuild } from '../lib/esbuild.js';
6
7
  import { importK2Config } from '../lib/import.js';
7
8
  import { getDefaultK2Config } from '../lib/k2.js';
@@ -35,7 +36,7 @@ export async function action(options) {
35
36
  console.log(`📁 ${Object.keys(entryPoints).length} entry points`);
36
37
  const k2Config = config ? await importK2Config(config) : getDefaultK2Config();
37
38
  const fullConfig = { ...k2Config, outDir };
38
- await Promise.allSettled([
39
+ const results = await Promise.allSettled([
39
40
  buildWithEsbuild({
40
41
  entryPoints,
41
42
  outdir,
@@ -45,6 +46,11 @@ export async function action(options) {
45
46
  }),
46
47
  buildTailwind(fullConfig),
47
48
  ]);
49
+ for (const result of results) {
50
+ if (result.status === 'rejected') {
51
+ throw result.reason;
52
+ }
53
+ }
48
54
  console.log('✨ Build success.');
49
55
  }
50
56
  catch (error) {
@@ -1,4 +1,5 @@
1
1
  import { program } from 'commander';
2
+ import {} from 'esbuild';
2
3
  import fs from 'fs-extra';
3
4
  import path from 'path';
4
5
  import { CONFIG_FILE_NAME, DEFAULT_PORT, DEVELOPMENT_DIRECTORY, WORKSPACE_DIRECTORY, } from '../../lib/constants.js';
@@ -1,3 +1,4 @@
1
+ import {} from 'esbuild';
1
2
  import path from 'path';
2
3
  import { getEsbuildContext } from '../lib/esbuild.js';
3
4
  export default async function action(params) {
@@ -1,6 +1,7 @@
1
1
  import { program } from 'commander';
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
+ import {} from 'webpack';
4
5
  import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
5
6
  import { importK2PluginConfig } from '../lib/import.js';
6
7
  import { getTailwindConfig, getTailwindInputCss, outputCss } from '../lib/tailwind.js';
@@ -1,4 +1,5 @@
1
1
  import { program } from 'commander';
2
+ import {} from 'esbuild';
2
3
  import fs from 'fs-extra';
3
4
  import path from 'path';
4
5
  import { DEFAULT_PORT, PLUGIN_DEVELOPMENT_DIRECTORY, PLUGIN_WORKSPACE_DIRECTORY, } from '../../lib/constants.js';
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import {} from 'tailwindcss';
2
3
  import { PLUGIN_DEVELOPMENT_DIRECTORY } from '../../lib/constants.js';
3
4
  import chalk from 'chalk';
4
5
  import { getTailwindConfig, getTailwindInputCss, watchTailwindCSS } from '../../lib/tailwind.js';
@@ -4,6 +4,7 @@ import path from 'path';
4
4
  import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
5
5
  import { importK2PluginConfig } from '../lib/import.js';
6
6
  import { getTailwindConfig, getTailwindInputCss, outputCss } from '../lib/tailwind.js';
7
+ import {} from 'esbuild';
7
8
  import { buildWithEsbuild } from '../lib/esbuild.js';
8
9
  import { lint } from '../lib/lint.js';
9
10
  export default function command() {
@@ -0,0 +1,64 @@
1
+ import { program } from 'commander';
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
5
+ import { importK2PluginConfig } from '../lib/import.js';
6
+ import { lint } from '../lib/lint.js';
7
+ import { getTailwindConfig, getTailwindInputCss, outputCss } from '../lib/tailwind.js';
8
+ import { buildWithTsup } from '../lib/tsup.js';
9
+ export default function command() {
10
+ program
11
+ .command('tsup')
12
+ .description("Build the project for production. (It's a wrapper of webpack build command.)")
13
+ .action(action);
14
+ }
15
+ export async function action() {
16
+ console.group('🍳 Build the project for production');
17
+ try {
18
+ const config = await importK2PluginConfig();
19
+ if (config?.lint?.build) {
20
+ await lint();
21
+ console.log('✨ Lint success.');
22
+ }
23
+ if (!fs.existsSync(PLUGIN_CONTENTS_DIRECTORY)) {
24
+ await fs.mkdir(PLUGIN_CONTENTS_DIRECTORY, { recursive: true });
25
+ }
26
+ if (config.tailwind?.css && config.tailwind?.config) {
27
+ const tailwindConfig = await getTailwindConfig(config.tailwind);
28
+ const inputFile = getTailwindInputCss(config.tailwind);
29
+ await outputCss({
30
+ inputPath: inputFile.config,
31
+ outputPath: path.join(PLUGIN_CONTENTS_DIRECTORY, 'config.css'),
32
+ config: tailwindConfig.config,
33
+ minify: true,
34
+ });
35
+ console.log('✨ Built config.css');
36
+ await outputCss({
37
+ inputPath: inputFile.desktop,
38
+ outputPath: path.join(PLUGIN_CONTENTS_DIRECTORY, 'desktop.css'),
39
+ config: tailwindConfig.desktop,
40
+ minify: true,
41
+ });
42
+ console.log('✨ Built desktop.css');
43
+ }
44
+ const entryPoints = ['desktop', 'config'].reduce((acc, dir) => ({
45
+ ...acc,
46
+ [dir]: path.join('src', dir, 'index.ts'),
47
+ }), {});
48
+ await buildWithTsup({
49
+ entryPoints,
50
+ outDir: PLUGIN_CONTENTS_DIRECTORY,
51
+ minify: true,
52
+ treeshake: true,
53
+ sourcemap: false,
54
+ });
55
+ console.log('✨ Built desktop.js and config.js');
56
+ console.log('✨ Build success.');
57
+ }
58
+ catch (error) {
59
+ throw error;
60
+ }
61
+ finally {
62
+ console.groupEnd();
63
+ }
64
+ }
package/dist/index.js CHANGED
@@ -1,18 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { program } from 'commander';
3
3
  import build from './commands/build.js';
4
- import viteBuild from './commands/build-vite.js';
5
4
  import dev from './commands/dev/index.js';
6
- import viteDev from './commands/dev-vite.js';
7
5
  import genkey from './commands/genkey.js';
8
6
  import esbuildBuild from './commands/build-esbuild.js';
9
7
  import lint from './commands/lint.js';
10
8
  program.name('k2').version('1.4.0').description('k2 - 🍳 kintone kitchen 🍳');
11
9
  build();
12
- viteBuild();
13
10
  esbuildBuild();
14
11
  dev();
15
- viteDev();
16
12
  genkey();
17
13
  lint();
18
14
  program.parse(process.argv);
@@ -1,3 +1,4 @@
1
+ import {} from 'esbuild';
1
2
  import { compile } from 'sass';
2
3
  import { resolve } from 'path';
3
4
  export const getSassPlugin = () => {
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import esbuild from 'esbuild';
2
+ import esbuild, {} from 'esbuild';
3
3
  import { getSassPlugin } from './esbuild-sass-plugin.js';
4
4
  const completeBuildOptions = (params) => {
5
5
  return {
package/dist/lib/lint.js CHANGED
@@ -1,44 +1,17 @@
1
1
  import { ESLint } from 'eslint';
2
+ import globals from 'globals';
3
+ import pluginJs from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+ import pluginReact from 'eslint-plugin-react';
2
6
  export async function lint() {
3
7
  const eslint = new ESLint({
4
- baseConfig: {
5
- env: {
6
- browser: true,
7
- es2021: true,
8
- },
9
- extends: [
10
- 'eslint:recommended',
11
- 'plugin:@typescript-eslint/recommended',
12
- 'plugin:react/recommended',
13
- 'prettier',
14
- ],
15
- parser: '@typescript-eslint/parser',
16
- parserOptions: {
17
- ecmaVersion: 'latest',
18
- sourceType: 'module',
19
- project: './tsconfig.json',
20
- ecmaFeatures: {
21
- jsx: true,
22
- },
23
- },
24
- plugins: ['@typescript-eslint', 'react'],
25
- rules: {
26
- 'react/prop-types': 'off',
27
- },
28
- overrides: [
29
- {
30
- files: ['*.ts', '*.tsx'],
31
- rules: {
32
- 'react/prop-types': 'off',
33
- },
34
- },
35
- ],
36
- settings: {
37
- react: {
38
- version: 'detect',
39
- },
40
- },
41
- },
8
+ baseConfig: [
9
+ { files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
10
+ { languageOptions: { globals: globals.browser } },
11
+ pluginJs.configs.recommended,
12
+ // ...tseslint.configs.recommended,
13
+ ...(pluginReact.configs.flat?.recommended ? [pluginReact.configs.flat.recommended] : []),
14
+ ],
42
15
  });
43
16
  const results = await eslint.lintFiles(['src/**/*.{ts,tsx?}']);
44
17
  const formatter = await eslint.loadFormatter('stylish');
@@ -5,7 +5,7 @@ import { glob } from 'glob';
5
5
  import path from 'path';
6
6
  import postcss from 'postcss';
7
7
  import { debounce } from 'remeda';
8
- import tailwindcss from 'tailwindcss';
8
+ import tailwindcss, {} from 'tailwindcss';
9
9
  import invariant from 'tiny-invariant';
10
10
  import { esmImport } from './import.js';
11
11
  export const getTailwindConfigFromK2Config = async (k2Config) => {
@@ -0,0 +1,27 @@
1
+ import { getSassPlugin } from './esbuild-sass-plugin.js';
2
+ import { build } from 'tsup';
3
+ /**
4
+ * 受け取ったビルドオプションに対して、共通するビルドオプションを補完します
5
+ *
6
+ * @param params
7
+ * @returns
8
+ */
9
+ const completeBuildOptions = (params) => {
10
+ return {
11
+ bundle: true,
12
+ minify: 'terser',
13
+ splitting: false,
14
+ noExternal: [/.*/],
15
+ platform: 'browser',
16
+ dts: true,
17
+ ...params,
18
+ esbuildOptions(options, context) {
19
+ options.legalComments = 'none';
20
+ },
21
+ esbuildPlugins: [...(params.esbuildPlugins ?? []), getSassPlugin()],
22
+ };
23
+ };
24
+ export const buildWithTsup = async (buildOptions) => {
25
+ const options = completeBuildOptions(buildOptions);
26
+ await build(options);
27
+ };
@@ -2,13 +2,17 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
2
2
  import path from 'path';
3
3
  import { cwd } from 'process';
4
4
  import TerserPlugin from 'terser-webpack-plugin';
5
- import webpack from 'webpack';
5
+ import webpack, {} from 'webpack';
6
6
  import chalk from 'chalk';
7
7
  import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
8
8
  export const buildWithWebpack = async (props) => {
9
9
  const { entries, outDir } = props;
10
10
  const exclude = /node_modules/;
11
11
  const styleLoader = MiniCssExtractPlugin.loader;
12
+ const tsConfigPath = path.join(cwd(), 'tsconfig.json');
13
+ console.group(chalk.blue('🚀 Building with Webpack...'));
14
+ console.log('🔧 tsconfig.json path:', tsConfigPath);
15
+ console.groupEnd();
12
16
  return new Promise((resolve, reject) => {
13
17
  webpack({
14
18
  mode: 'production',
@@ -19,7 +23,7 @@ export const buildWithWebpack = async (props) => {
19
23
  fallback: {
20
24
  path: false,
21
25
  },
22
- plugins: [new TsconfigPathsPlugin({ configFile: path.join(cwd(), 'tsconfig.json') })],
26
+ plugins: [new TsconfigPathsPlugin({ configFile: tsConfigPath })],
23
27
  },
24
28
  cache: { type: 'filesystem' },
25
29
  output: { filename: '[name].js', path: path.resolve(outDir) },
package/dist/plugin.js CHANGED
@@ -9,6 +9,7 @@ import manifest from './commands/manifest/index.js';
9
9
  import test from './commands/test/index.js';
10
10
  import zip from './commands/plugin-zip.js';
11
11
  import lint from './commands/lint.js';
12
+ import tsup from './commands/plugin-tsup.js';
12
13
  program.name('plugin').version('1.4.0').description('🍳 kintone kitchen 🍳 for kintone plugin');
13
14
  build();
14
15
  esbuild();
@@ -19,4 +20,5 @@ manifest();
19
20
  test();
20
21
  zip();
21
22
  lint();
23
+ tsup();
22
24
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/k2",
3
- "version": "1.7.7",
3
+ "version": "1.8.2",
4
4
  "description": "kintone sdk",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -15,7 +15,6 @@
15
15
  "types.d.ts"
16
16
  ],
17
17
  "scripts": {
18
- "prepare": "npm run build",
19
18
  "build": "rmdir /s /q dist & tsc",
20
19
  "dev": "tsc -w",
21
20
  "watch": "tsc -w"
@@ -24,27 +23,29 @@
24
23
  "author": "",
25
24
  "license": "ISC",
26
25
  "dependencies": {
26
+ "@eslint/js": "^9.17.0",
27
27
  "@kintone/plugin-packer": "^8",
28
- "@typescript-eslint/eslint-plugin": "^7",
29
- "@typescript-eslint/parser": "^7",
28
+ "@typescript-eslint/eslint-plugin": "^8",
29
+ "@typescript-eslint/parser": "^8",
30
30
  "archiver": "^7",
31
31
  "chalk": "^5",
32
32
  "chokidar": "^4",
33
- "commander": "^12",
33
+ "commander": "^13",
34
34
  "css-loader": "^7",
35
35
  "cssnano": "^7",
36
36
  "deepmerge": "^4",
37
37
  "dotenv": "^16",
38
38
  "esbuild": "^0.24",
39
- "eslint": "^8",
39
+ "eslint": "^9",
40
40
  "eslint-config-prettier": "^9",
41
41
  "eslint-plugin-import": "^2",
42
42
  "eslint-plugin-n": "^17",
43
- "eslint-plugin-promise": "^6",
43
+ "eslint-plugin-promise": "^7",
44
44
  "eslint-plugin-react": "^7",
45
45
  "express": "^4",
46
46
  "fs-extra": "^11",
47
47
  "glob": "^11.0.0",
48
+ "globals": "^15.14.0",
48
49
  "html-minifier": "^4",
49
50
  "mini-css-extract-plugin": "^2",
50
51
  "postcss": "^8",
@@ -57,16 +58,16 @@
57
58
  "tiny-invariant": "^1",
58
59
  "ts-loader": "^9",
59
60
  "tsconfig-paths-webpack-plugin": "^4",
60
- "vite": "^5",
61
- "vite-tsconfig-paths": "^5",
61
+ "tsup": "^8",
62
+ "typescript-eslint": "^8.19.0",
62
63
  "webpack": "^5"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@types/archiver": "*",
66
- "@types/eslint": "^8",
67
+ "@types/eslint": "^9",
67
68
  "@types/express": "^5",
68
69
  "@types/fs-extra": "*",
69
70
  "@types/html-minifier": "^4",
70
71
  "typescript": "*"
71
72
  }
72
- }
73
+ }
@@ -1,8 +0,0 @@
1
- import { build } from 'vite';
2
- export default async function action(params) {
3
- const { viteConfig } = params;
4
- await build({
5
- ...viteConfig,
6
- mode: 'production',
7
- });
8
- }
@@ -1,40 +0,0 @@
1
- import { program } from 'commander';
2
- import { getViteConfig } from '../lib/vite.js';
3
- import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
4
- import path from 'path';
5
- import base from './build-vite-base.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 viteConfig = getViteConfig({
16
- build: {
17
- rollupOptions: {
18
- input: {
19
- config: path.join('src', 'config', 'index.ts'),
20
- desktop: path.join('src', 'desktop', 'index.ts'),
21
- },
22
- output: {
23
- entryFileNames: '[name].js',
24
- chunkFileNames: '[name].js',
25
- assetFileNames: '[name].[ext]',
26
- },
27
- },
28
- outDir: PLUGIN_CONTENTS_DIRECTORY,
29
- },
30
- });
31
- await base({ viteConfig });
32
- console.log('✨ Build success.');
33
- }
34
- catch (error) {
35
- throw error;
36
- }
37
- finally {
38
- console.groupEnd();
39
- }
40
- }
@@ -1,50 +0,0 @@
1
- import { program } from 'commander';
2
- import { getViteConfig } from '../lib/vite.js';
3
- import { WORKSPACE_DIRECTORY } from '../lib/constants.js';
4
- import path from 'path';
5
- import base from './build-vite-base.js';
6
- import fs from 'fs-extra';
7
- export default function command() {
8
- program
9
- .command('vite-build')
10
- .option('-o, --outdir <outdir>', 'Output directory.', path.join(WORKSPACE_DIRECTORY, 'prod'))
11
- .option('-i, --input <input>', 'Input directory.', path.join('src', 'apps'))
12
- .description("Build the project for production. (It's a wrapper of webpack build command.)")
13
- .action(action);
14
- }
15
- export async function action(options) {
16
- console.group('🍳 Build the project for production');
17
- try {
18
- const { outdir, input } = options;
19
- const allProjects = fs.readdirSync(path.resolve(input));
20
- const entries = allProjects.reduce((acc, dir) => {
21
- for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
22
- if (fs.existsSync(path.join(input, dir, filename))) {
23
- return { ...acc, [dir]: path.join(input, dir, filename) };
24
- }
25
- }
26
- return acc;
27
- }, {});
28
- const viteConfig = getViteConfig({
29
- build: {
30
- rollupOptions: {
31
- input: entries,
32
- output: {
33
- entryFileNames: '[name].js',
34
- chunkFileNames: '[name].js',
35
- assetFileNames: '[name].[ext]',
36
- },
37
- },
38
- outDir: path.resolve(outdir),
39
- },
40
- });
41
- await base({ viteConfig });
42
- console.log('✨ Build success.');
43
- }
44
- catch (error) {
45
- throw error;
46
- }
47
- finally {
48
- console.groupEnd();
49
- }
50
- }
@@ -1,30 +0,0 @@
1
- import { createServer, build } from 'vite';
2
- import chokidar from 'chokidar';
3
- import { PLUGIN_DEVELOPMENT_DIRECTORY } from '../lib/constants.js';
4
- export default async function action(params) {
5
- console.group('🚀 Start development server');
6
- try {
7
- const { viteConfig } = params;
8
- const watcher = chokidar.watch(['src/**/*.{ts,js,jsx,tsx}'], {
9
- ignored: /node_modules/,
10
- persistent: true,
11
- });
12
- const listener = async () => build(viteConfig);
13
- await listener();
14
- watcher.on('change', listener);
15
- watcher.on('add', listener);
16
- watcher.on('unlink', listener);
17
- const server = await createServer({
18
- ...viteConfig,
19
- root: PLUGIN_DEVELOPMENT_DIRECTORY,
20
- });
21
- await server.listen();
22
- server.printUrls();
23
- }
24
- catch (error) {
25
- throw error;
26
- }
27
- finally {
28
- console.groupEnd();
29
- }
30
- }
@@ -1,63 +0,0 @@
1
- import { program } from 'commander';
2
- import { getViteConfig } from '../lib/vite.js';
3
- import { DEVELOPMENT_DIRECTORY, WORKSPACE_DIRECTORY } from '../lib/constants.js';
4
- import path from 'path';
5
- import { DEFAULT_PORT } from '../lib/constants.js';
6
- import fs from 'fs-extra';
7
- import base from './dev-vite-base.js';
8
- export default function command() {
9
- program
10
- .command('vite-dev')
11
- .description('Start development server.')
12
- .option('-i, --input <input>', 'Input directory', 'src/apps')
13
- .option('-o, --outdir <outdir>', 'Output directory.', DEVELOPMENT_DIRECTORY)
14
- .option('-c, --certdir <certdir>', 'Certificate directory', WORKSPACE_DIRECTORY)
15
- .option('-p, --port <port>', 'Port number', DEFAULT_PORT.toString())
16
- .action(action);
17
- }
18
- export async function action(options) {
19
- console.group('🚀 Start development server');
20
- try {
21
- const { certdir, outdir, port, srcdir } = options;
22
- const srcDir = path.resolve(srcdir);
23
- const dirs = fs.readdirSync(srcDir);
24
- const entryPoints = dirs.reduce((acc, dir) => {
25
- for (const filename of ['index.ts', 'index.js', 'index.mjs']) {
26
- if (fs.existsSync(path.join(srcDir, dir, filename))) {
27
- return { ...acc, [dir]: path.join(srcDir, dir, filename) };
28
- }
29
- }
30
- return acc;
31
- }, {});
32
- const viteConfig = getViteConfig({
33
- mode: 'development',
34
- build: {
35
- rollupOptions: {
36
- input: entryPoints,
37
- output: {
38
- entryFileNames: '[name].js',
39
- chunkFileNames: '[name].js',
40
- assetFileNames: '[name].[ext]',
41
- },
42
- },
43
- outDir: path.resolve(outdir),
44
- sourcemap: 'inline',
45
- chunkSizeWarningLimit: 8192,
46
- },
47
- server: {
48
- port: Number(port),
49
- https: {
50
- key: fs.readFileSync(path.join(certdir, 'localhost-key.pem')),
51
- cert: fs.readFileSync(path.join(certdir, 'localhost-cert.pem')),
52
- },
53
- },
54
- });
55
- await base({ viteConfig });
56
- }
57
- catch (error) {
58
- throw error;
59
- }
60
- finally {
61
- console.groupEnd();
62
- }
63
- }
package/dist/lib/vite.js DELETED
@@ -1,25 +0,0 @@
1
- import path from 'path';
2
- import tsconfigPaths from 'vite-tsconfig-paths';
3
- export const getViteConfig = (config) => {
4
- return {
5
- ...config,
6
- configFile: false,
7
- build: {
8
- ...config.build,
9
- rollupOptions: {
10
- ...config.build?.rollupOptions,
11
- onwarn: (warning, warn) => {
12
- if (['MODULE_LEVEL_DIRECTIVE'].includes(warning.code ?? '')) {
13
- return;
14
- }
15
- warn(warning);
16
- },
17
- },
18
- },
19
- plugins: [...(config.plugins ?? []), tsconfigPaths()],
20
- resolve: {
21
- ...config.resolve,
22
- alias: { '@': path.resolve('src') },
23
- },
24
- };
25
- };