@konomi-app/k2 1.4.2 → 1.4.4
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/plugin-build.js +2 -2
- package/dist/commands/plugin-dev/index.js +2 -2
- package/dist/commands/plugin-esbuild.js +2 -2
- package/dist/lib/import.js +1 -1
- package/dist/lib/plugin-contents.js +8 -4
- package/dist/lib/plugin-manifest.js +2 -2
- package/dist/lib/utils.js +25 -14
- package/dist/lib/webpack.js +6 -1
- package/dist/plugin.js +0 -2
- package/package.json +1 -2
- package/dist/commands/upload/index.js +0 -30
|
@@ -2,7 +2,7 @@ import { program } from 'commander';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { importK2PluginConfig } from '../lib/import.js';
|
|
6
6
|
import { getTailwindConfig, outputCss } from '../lib/tailwind.js';
|
|
7
7
|
import base from './build-base.js';
|
|
8
8
|
import { lint } from '../lib/lint.js';
|
|
@@ -15,7 +15,7 @@ export default function command() {
|
|
|
15
15
|
export async function action() {
|
|
16
16
|
console.group('🍳 Build the project for production');
|
|
17
17
|
try {
|
|
18
|
-
const config = await
|
|
18
|
+
const config = await importK2PluginConfig();
|
|
19
19
|
if (config?.lint?.build) {
|
|
20
20
|
await lint();
|
|
21
21
|
console.log('✨ Lint success.');
|
|
@@ -2,7 +2,7 @@ import { program } from 'commander';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { DEFAULT_PORT, PLUGIN_DEVELOPMENT_DIRECTORY, PLUGIN_WORKSPACE_DIRECTORY, } from '../../lib/constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { importK2PluginConfig } from '../../lib/import.js';
|
|
6
6
|
import base from '../dev-base-esbuild.js';
|
|
7
7
|
import { getManifest } from './create-manifest.js';
|
|
8
8
|
import { watchCss } from './tailwind.js';
|
|
@@ -18,7 +18,7 @@ export async function action(options) {
|
|
|
18
18
|
console.group('🍳 Start development server');
|
|
19
19
|
try {
|
|
20
20
|
const { ppk: ppkPath } = options;
|
|
21
|
-
const config = await
|
|
21
|
+
const config = await importK2PluginConfig();
|
|
22
22
|
if (!fs.existsSync(PLUGIN_DEVELOPMENT_DIRECTORY)) {
|
|
23
23
|
await fs.mkdir(PLUGIN_DEVELOPMENT_DIRECTORY, { recursive: true });
|
|
24
24
|
}
|
|
@@ -2,7 +2,7 @@ import { program } from 'commander';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { importK2PluginConfig } from '../lib/import.js';
|
|
6
6
|
import { getTailwindConfig, outputCss } from '../lib/tailwind.js';
|
|
7
7
|
import { buildWithEsbuild } from '../lib/esbuild.js';
|
|
8
8
|
import { lint } from '../lib/lint.js';
|
|
@@ -15,7 +15,7 @@ export default function command() {
|
|
|
15
15
|
export async function action() {
|
|
16
16
|
console.group('🍳 Build the project for production');
|
|
17
17
|
try {
|
|
18
|
-
const config = await
|
|
18
|
+
const config = await importK2PluginConfig();
|
|
19
19
|
if (config?.lint?.build) {
|
|
20
20
|
await lint();
|
|
21
21
|
console.log('✨ Lint success.');
|
package/dist/lib/import.js
CHANGED
|
@@ -12,6 +12,6 @@ export const esmImport = (path) => {
|
|
|
12
12
|
export const importK2Config = async (configFileName) => {
|
|
13
13
|
return (await esmImport(path.resolve(configFileName ?? CONFIG_FILE_NAME))).default;
|
|
14
14
|
};
|
|
15
|
-
export const
|
|
15
|
+
export const importK2PluginConfig = async (configFileName) => {
|
|
16
16
|
return (await esmImport(path.resolve(configFileName ?? PLUGIN_CONFIG_FILE_NAME))).default;
|
|
17
17
|
};
|
|
@@ -2,11 +2,15 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { PLUGIN_CONTENTS_DIRECTORY } from './constants.js';
|
|
4
4
|
import htmlMinifier from 'html-minifier';
|
|
5
|
-
export const copyPluginContents = async () => {
|
|
6
|
-
|
|
5
|
+
export const copyPluginContents = async (params = {}) => {
|
|
6
|
+
const { inputDir = path.join('src', 'contents'), outputDir = PLUGIN_CONTENTS_DIRECTORY } = params;
|
|
7
|
+
if (!fs.existsSync(inputDir)) {
|
|
8
|
+
await fs.mkdir(inputDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
await fs.copy(inputDir, path.join(outputDir), {
|
|
7
11
|
overwrite: true,
|
|
8
12
|
});
|
|
9
|
-
const html = await fs.readFile(path.join(
|
|
13
|
+
const html = await fs.readFile(path.join(outputDir, 'config.html'), 'utf8');
|
|
10
14
|
const minified = htmlMinifier.minify(html, {
|
|
11
15
|
minifyCSS: true,
|
|
12
16
|
collapseWhitespace: true,
|
|
@@ -17,5 +21,5 @@ export const copyPluginContents = async () => {
|
|
|
17
21
|
removeTagWhitespace: true,
|
|
18
22
|
useShortDoctype: true,
|
|
19
23
|
});
|
|
20
|
-
await fs.writeFile(path.join(
|
|
24
|
+
await fs.writeFile(path.join(outputDir, 'config.html'), minified);
|
|
21
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PLUGIN_CONTENTS_DIRECTORY } from './constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import { importK2PluginConfig } from './import.js';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
function merge(src, dst) {
|
|
@@ -17,7 +17,7 @@ function merge(src, dst) {
|
|
|
17
17
|
}, {});
|
|
18
18
|
}
|
|
19
19
|
export const outputManifest = async (env, options) => {
|
|
20
|
-
const config = options?.config || (await
|
|
20
|
+
const config = options?.config || (await importK2PluginConfig());
|
|
21
21
|
const merged = merge(config.manifest.base, config.manifest[env] || {});
|
|
22
22
|
await fs.mkdirs(PLUGIN_CONTENTS_DIRECTORY);
|
|
23
23
|
await fs.writeJson(path.join(PLUGIN_CONTENTS_DIRECTORY, 'manifest.json'), merged);
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PLUGIN_WORKSPACE_DIRECTORY } from './constants.js';
|
|
2
|
-
import { exec } from './exec.js';
|
|
3
2
|
import { KintoneApiClient } from './kintone-api-client.js';
|
|
4
3
|
import { getZipFileNameSuffix } from './zip.js';
|
|
5
|
-
import { config } from 'dotenv';
|
|
6
4
|
import fs from 'fs-extra';
|
|
7
5
|
import path from 'path';
|
|
8
6
|
export const isEnv = (env) => {
|
|
@@ -35,20 +33,33 @@ export const apiUploadZip = async (params) => {
|
|
|
35
33
|
/**
|
|
36
34
|
* @kintone/plugin-uploaderを利用してプラグインをアップロードします
|
|
37
35
|
* APIを使用した方が高速ですが、2024年11月までは設定により無効になる可能性があるため、暫定的に残しています
|
|
36
|
+
* 使用するには@kintone/plugin-uploaderがインストールされている必要があります
|
|
38
37
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
/*
|
|
39
|
+
export const uploadZip = async (env: Plugin.Meta.Env) => {
|
|
40
|
+
config();
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
KINTONE_BASE_URL,
|
|
44
|
+
KINTONE_USERNAME,
|
|
45
|
+
KINTONE_PASSWORD,
|
|
46
|
+
KINTONE_BASIC_AUTH_USERNAME = '',
|
|
47
|
+
KINTONE_BASIC_AUTH_PASSWORD = '',
|
|
48
|
+
} = process.env;
|
|
49
|
+
if (!KINTONE_BASE_URL || !KINTONE_USERNAME || !KINTONE_PASSWORD) {
|
|
50
|
+
throw new Error(`.envの設定が不十分です。以下のパラメータは必須です
|
|
44
51
|
KINTONE_BASE_URL
|
|
45
52
|
KINTONE_USERNAME
|
|
46
53
|
KINTONE_PASSWORD`);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const zipFileName = `plugin${getZipFileNameSuffix(env)}.zip`;
|
|
57
|
+
|
|
58
|
+
let command = `kintone-plugin-uploader ${PLUGIN_WORKSPACE_DIRECTORY}/${zipFileName} --base-url ${KINTONE_BASE_URL} --username ${KINTONE_USERNAME} --password ${KINTONE_PASSWORD}`;
|
|
59
|
+
if (KINTONE_BASIC_AUTH_USERNAME && KINTONE_BASIC_AUTH_PASSWORD) {
|
|
60
|
+
command += ` --basic-auth-username ${KINTONE_BASIC_AUTH_USERNAME} --basic-auth-password ${KINTONE_BASIC_AUTH_PASSWORD}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return exec(command);
|
|
54
64
|
};
|
|
65
|
+
*/
|
package/dist/lib/webpack.js
CHANGED
|
@@ -40,7 +40,12 @@ export const buildWithWebpack = async (props) => {
|
|
|
40
40
|
plugins: [new MiniCssExtractPlugin()],
|
|
41
41
|
optimization: {
|
|
42
42
|
minimize: true,
|
|
43
|
-
minimizer: [
|
|
43
|
+
minimizer: [
|
|
44
|
+
new TerserPlugin({
|
|
45
|
+
terserOptions: { format: { comments: false } },
|
|
46
|
+
extractComments: false,
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
44
49
|
},
|
|
45
50
|
}, (err, stats) => {
|
|
46
51
|
if (err) {
|
package/dist/plugin.js
CHANGED
|
@@ -7,7 +7,6 @@ import genkey from './commands/plugin-genkey.js';
|
|
|
7
7
|
import init from './commands/plugin-init.js';
|
|
8
8
|
import manifest from './commands/manifest/index.js';
|
|
9
9
|
import test from './commands/test/index.js';
|
|
10
|
-
import upload from './commands/upload/index.js';
|
|
11
10
|
import zip from './commands/plugin-zip.js';
|
|
12
11
|
import lint from './commands/lint.js';
|
|
13
12
|
program.name('plugin').version('1.4.0').description('🍳 kintone kitchen 🍳 for kintone plugin');
|
|
@@ -18,7 +17,6 @@ genkey();
|
|
|
18
17
|
init();
|
|
19
18
|
manifest();
|
|
20
19
|
test();
|
|
21
|
-
upload();
|
|
22
20
|
zip();
|
|
23
21
|
lint();
|
|
24
22
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomi-app/k2",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "kintone sdk",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@kintone/plugin-packer": "^8",
|
|
28
|
-
"@kintone/plugin-uploader": "^9",
|
|
29
28
|
"@typescript-eslint/eslint-plugin": "^7",
|
|
30
29
|
"@typescript-eslint/parser": "^7",
|
|
31
30
|
"archiver": "^7",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { program } from 'commander';
|
|
2
|
-
import { config } from 'dotenv';
|
|
3
|
-
import { isEnv, uploadZip } from '../../lib/utils.js';
|
|
4
|
-
export default function command() {
|
|
5
|
-
program
|
|
6
|
-
.command('upload')
|
|
7
|
-
.description('upload plugin.zip to your kintone')
|
|
8
|
-
.option('-e, --env <env>', 'plugin environment (dev, prod, standalone)', 'prod')
|
|
9
|
-
.action(action);
|
|
10
|
-
}
|
|
11
|
-
async function action(options) {
|
|
12
|
-
console.group('🚀 Uploading plugin.zip to your kintone');
|
|
13
|
-
try {
|
|
14
|
-
config();
|
|
15
|
-
const { env } = options;
|
|
16
|
-
if (!isEnv(env)) {
|
|
17
|
-
throw new Error('Invalid environment');
|
|
18
|
-
}
|
|
19
|
-
const { stderr } = await uploadZip(env);
|
|
20
|
-
if (stderr) {
|
|
21
|
-
console.error(JSON.stringify(stderr, null, 2));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
console.groupEnd();
|
|
29
|
-
}
|
|
30
|
-
}
|