Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create-plugin: Refactor getTemplateData to be used in generate command and update commands #837

Merged
merged 29 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
26f673f
Create Plugins: Fix plugin add mismatch
oshirohugo Mar 21, 2024
ce6962b
Update test
oshirohugo Mar 21, 2024
5e2adce
WIP
Ukochka Mar 22, 2024
56f435a
Delete console log and commented lines
Ukochka Mar 22, 2024
966fae0
Remove normalize_id
oshirohugo Apr 2, 2024
55a1eb8
WIP
Ukochka Apr 3, 2024
121f1f9
resetting handelbars changes
Ukochka Apr 4, 2024
612f13b
Merge branch 'main' into refactor-template-generation
Ukochka Apr 4, 2024
e7b4521
Merge branch 'fix-plugin-id-mismatch' into refactor-template-generation
Ukochka Apr 4, 2024
06852bc
delete proxy, update normalizeId
Ukochka Apr 4, 2024
814d3bc
Merge branch 'main' into refactor-template-generation
Ukochka Apr 8, 2024
72f4884
fix build
Ukochka Apr 8, 2024
cbf23dc
Pairing
leventebalogh Apr 15, 2024
8245a71
Docs: Clarify exception for signing plugin (#803)
josmperez Apr 8, 2024
a0e8abf
Revert "Docs: Add a router or multiplexer" (#864)
josmperez Apr 8, 2024
de7b92e
Docs: Plugin E2E - Panel plugin docs (#852)
sunker Apr 9, 2024
c2e4b11
Plugin E2E: Click on panel menu items (#865)
sunker Apr 9, 2024
1f6eda3
Update CHANGELOG.md [skip ci]
grafanabot Apr 9, 2024
c8f8dda
"Bump independent versions [skip ci]"
grafanabot Apr 9, 2024
1022847
Docs: Add plugin-e2e to NPM packages table (#866)
jackw Apr 10, 2024
052b648
fix errors after pairing session
Ukochka Apr 16, 2024
d2ae256
remove unused import
Ukochka Apr 16, 2024
4cc09ca
Merge branch 'main' into refactor-template-generation
Ukochka Apr 17, 2024
cb04f3c
Merge branch 'main' into refactor-template-generation
Ukochka Apr 22, 2024
3704df6
Merge branch 'main' into refactor-template-generation
Ukochka Apr 26, 2024
3b26a98
WIP Pairing with Levi
Ukochka Apr 26, 2024
e908374
Revert "WIP Pairing with Levi"
leventebalogh Apr 29, 2024
be8181f
Update: don't use a `Partial<TemplateData>` as input argument
leventebalogh Apr 29, 2024
e9165e7
Fix: fix type-errors
leventebalogh Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/create-plugin/src/commands/generate.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { DEFAULT_FEATURE_FLAGS, EXTRA_TEMPLATE_VARIABLES, IS_DEV, PLUGIN_TYPES,
import { getConfig } from '../utils/utils.config.js';
import { printError } from '../utils/utils.console.js';
import { directoryExists, getExportFileName, isFile } from '../utils/utils.files.js';
import { getPackageManagerFromUserAgent, getPackageManagerInstallCmd } from '../utils/utils.packageManager.js';
import { getExportPath } from '../utils/utils.path.js';
import { renderTemplateFromFile, getTemplateData } from '../utils/utils.templates.js';
import { normalizeId } from '../utils/utils.handlebars.js';
Expand All @@ -20,9 +19,8 @@ import { CliArgs, TemplateData } from '../types.js';

export const generate = async (argv: minimist.ParsedArgs) => {
const answers = await promptUser(argv);
const { packageManagerName, packageManagerVersion } = getPackageManagerFromUserAgent();
const pluginId = normalizeId(answers.pluginName, answers.orgName, answers.pluginType);
const templateData = getTemplateData({ ...answers, pluginId, packageManagerName, packageManagerVersion });
const templateData = getTemplateData({ ...answers, pluginId });
const exportPath = getExportPath(templateData.pluginName, templateData.orgName, templateData.pluginType);
const exportPathExists = await directoryExists(exportPath);
const exportPathIsPopulated = exportPathExists ? (await readdir(exportPath)).length > 0 : false;
Expand Down
20 changes: 10 additions & 10 deletions packages/create-plugin/src/utils/utils.templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export function renderTemplateFromFile(templateFile: string, data?: any) {
export function getTemplateData(data?: Partial<TemplateData>): TemplateData {
const { features } = getConfig();
const currentVersion = getVersion();
const pluginJson = getPluginJson();
const pluginType = data?.pluginType ?? pluginJson.type;
const packageManagerInfo = getPackageManagerWithFallback();
const packageManagerName = data?.packageManagerName ?? packageManagerInfo.packageManagerName;
const pluginJson = data ? undefined : getPluginJson();
leventebalogh marked this conversation as resolved.
Show resolved Hide resolved
const pluginType = data?.pluginType ?? pluginJson?.type;
const packageManagerInfo = data ? getPackageManagerFromUserAgent() : getPackageManagerWithFallback();
leventebalogh marked this conversation as resolved.
Show resolved Hide resolved
const packageManagerName = packageManagerInfo.packageManagerName;
const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManagerName);
const useReactRouterV6 = features.useReactRouterV6 === true && pluginType === PLUGIN_TYPES.app;
const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
Expand All @@ -113,15 +113,15 @@ export function getTemplateData(data?: Partial<TemplateData>): TemplateData {

const templateData = {
...EXTRA_TEMPLATE_VARIABLES,
pluginId: data?.pluginId ?? pluginJson.id,
pluginName: data?.pluginName ?? pluginJson.name,
pluginDescription: data?.pluginName ?? pluginJson.info?.description,
hasBackend: data?.hasBackend ?? pluginJson.backend,
orgName: data?.orgName ?? pluginJson.info?.author?.name,
pluginId: data?.pluginId ?? pluginJson?.id,
pluginName: data?.pluginName ?? pluginJson?.name,
pluginDescription: data?.pluginName ?? pluginJson?.info?.description,
hasBackend: data?.hasBackend ?? pluginJson?.backend,
orgName: data?.orgName ?? pluginJson?.info?.author?.name,
pluginType,
packageManagerName: packageManagerName,
packageManagerInstallCmd: packageManagerInstallCmd,
packageManagerVersion: data?.packageManagerVersion ?? packageManagerInfo.packageManagerVersion,
packageManagerVersion: packageManagerInfo.packageManagerVersion,
isAppType: pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes,
isNPM: packageManagerName === 'npm',
version: currentVersion,
Expand Down
Loading