Skip to content

Commit

Permalink
feat(create-plugin): show prompt to choose Spanish support (#2770)
Browse files Browse the repository at this point in the history
Co-authored-by: hung-nguyen <[email protected]>
  • Loading branch information
tuanphamcybozu and hung-cybo authored May 22, 2024
1 parent 70e5d03 commit c98ab15
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 84 deletions.
4 changes: 4 additions & 0 deletions packages/create-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ Let's start!
? Does your plugin support Chinese? Yes
? Input your plugin name in Chinese [1-64chars] (Optional)
? Input your plugin description in Chinese [1-200chars] (Optional)
? Does your plug-in support Spanish?
? Input your plug-in name in Spanish [1-64chars] (Optional)
? Input your plug-in description in Spanish [1-200chars] (Optional)
? Input your home page url for English (Optional)
? Input your home page url for Japanese (Optional)
? Input your home page url for Chinese (Optional)
? Input your home page url for Spanish (Optional)
? Does your plugin support mobile views? Yes
? Do you use @kintone/plugin-uploader? Yes
:
Expand Down
74 changes: 3 additions & 71 deletions packages/create-plugin/__e2e__/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import assert from "assert";
import type { QuestionInput } from "./utils/CreatePlugin";
import type { PluginTemplate } from "./utils/verification";
import {
CREATE_PLUGIN_COMMAND,
DEFAULT_ANSWER,
ANSWER_NO,
} from "./utils/constants";
import path from "path";
import { generateWorkingDir } from "./utils/helper";
import fs from "fs";
Expand All @@ -14,7 +9,6 @@ import {
assertObjectIncludes,
readPluginManifestJson,
} from "./utils/verification";
import { getBoundMessage } from "../src/messages";
import { CreatePlugin } from "./utils/CreatePlugin";
import {
requiredOptions,
Expand All @@ -24,9 +18,10 @@ import {
languageEN,
languageJA,
emptyOutputDir,
existOutputDir,
forbiddenCharacters,
pluginNameContain65Chars,
pluginDescriptionContain201Chars,
existOutputDir,
createKintonePluginCommand,
minimumTemplate,
modernTemplate,
Expand Down Expand Up @@ -71,6 +66,7 @@ describe("create-plugin", function () {
modernTemplate,
emptyOutputDir,
existOutputDir,
forbiddenCharacters,
pluginNameContain65Chars,
pluginDescriptionContain201Chars,
createKintonePluginCommand,
Expand Down Expand Up @@ -121,70 +117,6 @@ describe("create-plugin", function () {
}
});

it("#JsSdkTest-11 Should throw an error when the output directory contains forbidden characters", async () => {
const m = getBoundMessage("en");
let outputDir: string;
const isWindows = process.platform === "win32";
if (isWindows) {
outputDir = ":";
} else {
outputDir = "/";
}

const questionsInput: QuestionInput[] = [
{
question: m("Q_NameEn"),
answer: "test11-name",
},
{
question: m("Q_DescriptionEn"),
answer: "test11-description",
},
{
question: m("Q_SupportJa"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_SupportZh"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_NO,
},
{
question: m("Q_EnablePluginUploader"),
answer: ANSWER_NO,
},
];

const createPlugin = new CreatePlugin({
command: CREATE_PLUGIN_COMMAND,
workingDir,
outputDir,
questionsInput,
});
const response = await createPlugin.executeCommand();

if (isWindows) {
assert.equal(response.status, 1);
assert.match(
response.stderr.trim(),
/Could not create a plug-in project. Error:\nEINVAL: invalid argument, mkdir '.*:'/,
);
} else {
assert.notEqual(response.status, 0);
assert.match(
response.stderr.trim(),
/Error: \/ already exists. Choose a different directory/,
);
}
});

afterEach(() => {
const testName = expect.getState().currentTestName;
if (!testName || !workingDir) {
Expand Down
19 changes: 19 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/allOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ export const pattern: TestPattern = {
question: m("Q_DescriptionZh"),
answer: "我的插件",
},
{
question: m("Q_SupportEs"),
answer: ANSWER_YES,
},
{
question: m("Q_NameEs"),
answer: "test4-nombre",
},
{
question: m("Q_DescriptionEs"),
answer: "test4-descripción",
},
{
question: m("Q_WebsiteUrlEn"),
answer: "https://github.com",
Expand All @@ -55,6 +67,10 @@ export const pattern: TestPattern = {
question: m("Q_WebsiteUrlZh"),
answer: "https://github.cn",
},
{
question: m("Q_WebsiteUrlEs"),
answer: "https://github.es",
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_YES,
Expand All @@ -72,16 +88,19 @@ export const pattern: TestPattern = {
en: "test4-name",
ja: "私のプラグイン",
zh: "我的插件",
es: "test4-nombre",
},
description: {
en: "test4-description",
ja: "私のプラグイン",
zh: "我的插件",
es: "test4-descripción",
},
homepage_url: {
en: "https://github.com",
ja: "https://github.jp",
zh: "https://github.cn",
es: "https://github.es",
},
mobile: {
js: ["js/mobile.js"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ export const pattern: TestPattern = {
question: m("Q_DescriptionZh"),
answer: "我的插件",
},
{
question: m("Q_SupportEs"),
answer: ANSWER_YES,
},
{
question: m("Q_NameEs"),
answer: "test14-nombre",
},
{
question: m("Q_DescriptionEs"),
answer: "test14-descripción",
},
{
question: m("Q_WebsiteUrlEn"),
answer: "https://github.com",
Expand All @@ -55,6 +67,10 @@ export const pattern: TestPattern = {
question: m("Q_WebsiteUrlZh"),
answer: "https://github.cn",
},
{
question: m("Q_WebsiteUrlEs"),
answer: "https://github.es",
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_YES,
Expand All @@ -72,16 +88,19 @@ export const pattern: TestPattern = {
en: "test14-name",
ja: "私のプラグイン",
zh: "我的插件",
es: "test14-nombre",
},
description: {
en: "test14-description",
ja: "私のプラグイン",
zh: "我的插件",
es: "test14-descripción",
},
homepage_url: {
en: "https://github.com",
ja: "https://github.jp",
zh: "https://github.cn",
es: "https://github.es",
},
mobile: {
js: ["js/mobile.js"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const pattern: TestPattern = {
question: m("Q_SupportZh"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_SupportEs"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
Expand Down
3 changes: 2 additions & 1 deletion packages/create-plugin/__e2e__/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ export { pattern as allOptions } from "./allOptions";
export { pattern as languageEN } from "./languageEN";
export { pattern as languageJA } from "./languageJA";
export { pattern as emptyOutputDir } from "./emptyOutputDir";
export { pattern as existOutputDir } from "./existOutputDir";
export { pattern as forbiddenCharacters } from "./forbiddenCharacters";
export { pattern as pluginNameContain65Chars } from "./pluginNameContain65Chars";
export { pattern as pluginDescriptionContain201Chars } from "./pluginDescriptionContain201Chars";
export { pattern as existOutputDir } from "./existOutputDir";
export { pattern as createKintonePluginCommand } from "./createKintonePluginCommand";
export { pattern as minimumTemplate } from "./minimumTemplate";
export { pattern as modernTemplate } from "./modernTemplate";
19 changes: 19 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/languageEN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export const pattern: TestPattern = {
question: m("Q_DescriptionZh"),
answer: "我的插件",
},
{
question: m("Q_SupportEs"),
answer: ANSWER_YES,
},
{
question: m("Q_NameEs"),
answer: "test5-nombre",
},
{
question: m("Q_DescriptionEs"),
answer: "test5-descripción",
},
{
question: m("Q_WebsiteUrlEn"),
answer: "https://github.com",
Expand All @@ -61,6 +73,10 @@ export const pattern: TestPattern = {
question: m("Q_WebsiteUrlZh"),
answer: "https://github.cn",
},
{
question: m("Q_WebsiteUrlEs"),
answer: "https://github.es",
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_NO,
Expand All @@ -78,16 +94,19 @@ export const pattern: TestPattern = {
en: "test5-name",
ja: "私のプラグイン",
zh: "我的插件",
es: "test5-nombre",
},
description: {
en: "test5-description",
ja: "私のプラグイン",
zh: "我的插件",
es: "test5-descripción",
},
homepage_url: {
en: "https://github.com",
ja: "https://github.jp",
zh: "https://github.cn",
es: "https://github.es",
},
},
},
Expand Down
19 changes: 19 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/languageJA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ export const pattern: TestPattern = {
question: m("Q_DescriptionZh"),
answer: "我的插件",
},
{
question: m("Q_SupportEs"),
answer: ANSWER_YES,
},
{
question: m("Q_NameEs"),
answer: "test6-nombre",
},
{
question: m("Q_DescriptionEs"),
answer: "test6-descripción",
},
{
question: m("Q_WebsiteUrlEn"),
answer: "https://github.com",
Expand All @@ -61,6 +73,10 @@ export const pattern: TestPattern = {
question: m("Q_WebsiteUrlZh"),
answer: "https://github.cn",
},
{
question: m("Q_WebsiteUrlEs"),
answer: "https://github.es",
},
{
question: m("Q_MobileSupport"),
answer: ANSWER_NO,
Expand All @@ -78,16 +94,19 @@ export const pattern: TestPattern = {
en: "test6-name",
ja: "私のプラグイン",
zh: "我的插件",
es: "test6-nombre",
},
description: {
en: "test6-description",
ja: "私のプラグイン",
zh: "我的插件",
es: "test6-descripción",
},
homepage_url: {
en: "https://github.com",
ja: "https://github.jp",
zh: "https://github.cn",
es: "https://github.es",
},
},
},
Expand Down
4 changes: 4 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/minimumTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const pattern: TestPattern = {
question: m("Q_SupportZh"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_SupportEs"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
Expand Down
4 changes: 4 additions & 0 deletions packages/create-plugin/__e2e__/fixtures/modernTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const pattern: TestPattern = {
question: m("Q_SupportZh"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_SupportEs"),
answer: DEFAULT_ANSWER,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const pattern: TestPattern = {
question: m("Q_SupportZh"),
answer: ANSWER_NO,
},
{
question: m("Q_SupportEs"),
answer: ANSWER_NO,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export const pattern: TestPattern = {
question: m("Q_SupportZh"),
answer: ANSWER_NO,
},
{
question: m("Q_SupportEs"),
answer: ANSWER_NO,
},
{
question: m("Q_WebsiteUrlEn"),
answer: DEFAULT_ANSWER,
Expand Down
Loading

0 comments on commit c98ab15

Please sign in to comment.