@konomi-app/k2 0.7.0 → 0.8.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.
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { program } from 'commander';
|
|
2
|
-
import
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { PLUGIN_CONTENTS_DIRECTORY } from '../lib/constants.js';
|
|
5
|
+
import { importPluginConfig } from '../lib/import.js';
|
|
6
|
+
import { getTailwindConfig, outputCss } from '../lib/tailwind.js';
|
|
4
7
|
import base from './build-base.js';
|
|
5
8
|
export default function command() {
|
|
6
9
|
program
|
|
@@ -11,11 +14,36 @@ export default function command() {
|
|
|
11
14
|
export async function action() {
|
|
12
15
|
console.group('🍳 Build the project for production');
|
|
13
16
|
try {
|
|
17
|
+
const config = await importPluginConfig();
|
|
18
|
+
if (!fs.existsSync(PLUGIN_CONTENTS_DIRECTORY)) {
|
|
19
|
+
await fs.mkdir(PLUGIN_CONTENTS_DIRECTORY, { recursive: true });
|
|
20
|
+
}
|
|
14
21
|
const entries = {
|
|
15
22
|
desktop: path.join('src', 'desktop', 'index.ts'),
|
|
16
23
|
config: path.join('src', 'config', 'index.ts'),
|
|
17
24
|
};
|
|
25
|
+
if (config.tailwind?.css && config.tailwind?.config) {
|
|
26
|
+
const tailwindConfig = await getTailwindConfig(config.tailwind);
|
|
27
|
+
const inputFile = path.resolve(config.tailwind.css);
|
|
28
|
+
const inputPath = path.resolve(inputFile);
|
|
29
|
+
const css = await fs.readFile(inputPath, 'utf8');
|
|
30
|
+
await outputCss({
|
|
31
|
+
css,
|
|
32
|
+
inputPath,
|
|
33
|
+
outputPath: path.join(PLUGIN_CONTENTS_DIRECTORY, 'config.css'),
|
|
34
|
+
config: tailwindConfig.config,
|
|
35
|
+
});
|
|
36
|
+
console.log('✨ Built config.css');
|
|
37
|
+
await outputCss({
|
|
38
|
+
css,
|
|
39
|
+
inputPath,
|
|
40
|
+
outputPath: path.join(PLUGIN_CONTENTS_DIRECTORY, 'desktop.css'),
|
|
41
|
+
config: tailwindConfig.config,
|
|
42
|
+
});
|
|
43
|
+
console.log('✨ Built desktop.css');
|
|
44
|
+
}
|
|
18
45
|
await base({ entries, outDir: PLUGIN_CONTENTS_DIRECTORY });
|
|
46
|
+
console.log('✨ Built desktop.js and config.js');
|
|
19
47
|
console.log('✨ Build success.');
|
|
20
48
|
}
|
|
21
49
|
catch (error) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import postcss from 'postcss';
|
|
4
|
-
import tailwindcss from 'tailwindcss';
|
|
5
3
|
import { PLUGIN_DEVELOPMENT_DIRECTORY } from '../../lib/constants.js';
|
|
6
|
-
import { esmImport } from '../../lib/import.js';
|
|
7
4
|
import chokidar from 'chokidar';
|
|
8
5
|
import chalk from 'chalk';
|
|
6
|
+
import { getTailwindConfig, outputCss } from '../../lib/tailwind.js';
|
|
9
7
|
async function buildTailwindCSS(params) {
|
|
10
8
|
const { inputFile, outputFileName, config } = params;
|
|
11
9
|
const inputPath = path.resolve(inputFile);
|
|
@@ -25,14 +23,7 @@ async function buildTailwindCSS(params) {
|
|
|
25
23
|
if (type === 'add' && !initialScanComplete) {
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
from: inputPath,
|
|
30
|
-
to: outputPath,
|
|
31
|
-
});
|
|
32
|
-
await fs.writeFile(outputPath, result.css);
|
|
33
|
-
if (result.map) {
|
|
34
|
-
await fs.writeFile(`${outputPath}.map`, result.map.toString());
|
|
35
|
-
}
|
|
26
|
+
await outputCss({ css, inputPath, outputPath, config });
|
|
36
27
|
console.log(chalk.hex('#e5e7eb')(`${new Date().toLocaleTimeString()} `) +
|
|
37
28
|
chalk.cyan(`[css] `) +
|
|
38
29
|
outputFileName +
|
|
@@ -42,9 +33,9 @@ async function buildTailwindCSS(params) {
|
|
|
42
33
|
console.error('Error building Tailwind CSS:', error);
|
|
43
34
|
}
|
|
44
35
|
};
|
|
45
|
-
|
|
46
|
-
watcher.on('ready', () => {
|
|
36
|
+
watcher.on('ready', async () => {
|
|
47
37
|
initialScanComplete = true;
|
|
38
|
+
await listener('init');
|
|
48
39
|
});
|
|
49
40
|
watcher.on('change', (path) => listener('change', path));
|
|
50
41
|
watcher.on('add', (path) => listener('add', path));
|
|
@@ -54,14 +45,10 @@ export const watchCss = async (pluginConfig) => {
|
|
|
54
45
|
if (!pluginConfig.tailwind?.css || !pluginConfig.tailwind?.config) {
|
|
55
46
|
return;
|
|
56
47
|
}
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const configPathForConfig = typeof configPath === 'string' ? configPath : configPath.config;
|
|
60
|
-
const desktopConfig = (await esmImport(path.resolve(configPathForDesktop))).default;
|
|
61
|
-
const configConfig = (await esmImport(path.resolve(configPathForConfig))).default;
|
|
62
|
-
const inputFile = path.resolve(css);
|
|
48
|
+
const tailwindConfig = await getTailwindConfig(pluginConfig.tailwind);
|
|
49
|
+
const inputFile = path.resolve(pluginConfig.tailwind.css);
|
|
63
50
|
return Promise.all([
|
|
64
|
-
buildTailwindCSS({ inputFile, outputFileName: 'desktop.css', config:
|
|
65
|
-
buildTailwindCSS({ inputFile, outputFileName: 'config.css', config:
|
|
51
|
+
buildTailwindCSS({ inputFile, outputFileName: 'desktop.css', config: tailwindConfig.desktop }),
|
|
52
|
+
buildTailwindCSS({ inputFile, outputFileName: 'config.css', config: tailwindConfig.config }),
|
|
66
53
|
]);
|
|
67
54
|
};
|
|
@@ -24,17 +24,26 @@ export const watchContentsAndUploadZip = async (params) => {
|
|
|
24
24
|
console.error('Error copying plugin contents:', error);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
chalk.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
try {
|
|
28
|
+
await outputContentsZip(manifest);
|
|
29
|
+
const buffer = await getContentsZipBuffer();
|
|
30
|
+
const pluginPrivateKey = await fs.readFile(path.resolve(ppkPath), 'utf8');
|
|
31
|
+
const output = await packer(buffer, pluginPrivateKey);
|
|
32
|
+
const zipFileName = `plugin${getZipFileNameSuffix('dev')}.zip`;
|
|
33
|
+
await fs.writeFile(path.join(PLUGIN_WORKSPACE_DIRECTORY, zipFileName), output.plugin);
|
|
34
|
+
console.log(chalk.hex('#e5e7eb')(`${new Date().toLocaleTimeString()} `) +
|
|
35
|
+
chalk.cyan(`[upload] `) +
|
|
36
|
+
`start uploading`);
|
|
37
|
+
await uploadZip('dev');
|
|
38
|
+
console.log(chalk.hex('#e5e7eb')(`${new Date().toLocaleTimeString()} `) +
|
|
39
|
+
chalk.cyan(`[upload] `) +
|
|
40
|
+
`done`);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log(chalk.hex('#e5e7eb')(`${new Date().toLocaleTimeString()} `) +
|
|
44
|
+
chalk.cyan(`[upload] `) +
|
|
45
|
+
chalk.red(`failed`));
|
|
46
|
+
}
|
|
38
47
|
};
|
|
39
48
|
const contentsWatcher = chokider.watch(['src/contents/**/*'], {
|
|
40
49
|
ignored: /node_modules/,
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import dev from './commands/dev.js';
|
|
|
6
6
|
import viteDev from './commands/dev-vite.js';
|
|
7
7
|
import genkey from './commands/genkey.js';
|
|
8
8
|
import esbuildBuild from './commands/build-esbuild.js';
|
|
9
|
-
program.name('k2').version('0.
|
|
9
|
+
program.name('k2').version('0.8.0').description('k2 - 🍳 kintone kitchen 🍳');
|
|
10
10
|
build();
|
|
11
11
|
viteBuild();
|
|
12
12
|
esbuildBuild();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import cssnanoPlugin from 'cssnano';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import postcss from 'postcss';
|
|
5
|
+
import tailwindcss from 'tailwindcss';
|
|
6
|
+
import invariant from 'tiny-invariant';
|
|
7
|
+
import { esmImport } from './import.js';
|
|
8
|
+
export const getTailwindConfig = async (config) => {
|
|
9
|
+
invariant(config?.config, 'tailwind.config is required');
|
|
10
|
+
const { config: configPath } = config;
|
|
11
|
+
const configPathForDesktop = typeof configPath === 'string' ? configPath : configPath.desktop;
|
|
12
|
+
const configPathForConfig = typeof configPath === 'string' ? configPath : configPath.config;
|
|
13
|
+
const desktopConfig = (await esmImport(path.resolve(configPathForDesktop))).default;
|
|
14
|
+
const configConfig = (await esmImport(path.resolve(configPathForConfig))).default;
|
|
15
|
+
return { desktop: desktopConfig, config: configConfig };
|
|
16
|
+
};
|
|
17
|
+
export const outputCss = async (params) => {
|
|
18
|
+
const { inputPath, outputPath, config, css, minify = false } = params;
|
|
19
|
+
const result = await postcss([tailwindcss(config), ...(minify ? [cssnanoPlugin()] : [])]).process(css, {
|
|
20
|
+
from: inputPath,
|
|
21
|
+
to: outputPath,
|
|
22
|
+
});
|
|
23
|
+
await fs.writeFile(outputPath, result.css);
|
|
24
|
+
if (result.map) {
|
|
25
|
+
await fs.writeFile(`${outputPath}.map`, result.map.toString());
|
|
26
|
+
}
|
|
27
|
+
};
|
package/dist/plugin.js
CHANGED
|
@@ -8,7 +8,7 @@ import manifest from './commands/manifest/index.js';
|
|
|
8
8
|
import test from './commands/test/index.js';
|
|
9
9
|
import upload from './commands/upload/index.js';
|
|
10
10
|
import zip from './commands/plugin-zip.js';
|
|
11
|
-
program.name('plugin').version('0.
|
|
11
|
+
program.name('plugin').version('0.8.0').description('🍳 kintone kitchen 🍳 for kintone plugin');
|
|
12
12
|
build();
|
|
13
13
|
dev();
|
|
14
14
|
genkey();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomi-app/k2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "kintone sdk",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"chokidar": "^3",
|
|
32
32
|
"commander": "^12",
|
|
33
33
|
"css-loader": "^7.1.2",
|
|
34
|
+
"cssnano": "^7.0.2",
|
|
34
35
|
"dotenv": "^16",
|
|
35
36
|
"esbuild": "^0.21",
|
|
36
37
|
"express": "^4",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"style-loader": "^4",
|
|
44
45
|
"tailwindcss": "^3.4.4",
|
|
45
46
|
"terser-webpack-plugin": "^5",
|
|
47
|
+
"tiny-invariant": "^1.3.3",
|
|
46
48
|
"ts-loader": "^9",
|
|
47
49
|
"tsconfig-paths-webpack-plugin": "^4",
|
|
48
50
|
"vite": "^5",
|