@konomi-app/k2 1.4.3 → 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.
@@ -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 { importPluginConfig } from '../lib/import.js';
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 importPluginConfig();
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 { importPluginConfig } from '../../lib/import.js';
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 importPluginConfig();
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 { importPluginConfig } from '../lib/import.js';
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 importPluginConfig();
18
+ const config = await importK2PluginConfig();
19
19
  if (config?.lint?.build) {
20
20
  await lint();
21
21
  console.log('✨ Lint success.');
@@ -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 importPluginConfig = async (configFileName) => {
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
- await fs.copySync(path.join('src', 'contents'), path.join(PLUGIN_CONTENTS_DIRECTORY), {
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(PLUGIN_CONTENTS_DIRECTORY, 'config.html'), 'utf8');
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(PLUGIN_CONTENTS_DIRECTORY, 'config.html'), minified);
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 { importPluginConfig } from './import.js';
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 importPluginConfig());
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konomi-app/k2",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "kintone sdk",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",