Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoruaFox committed Feb 21, 2024
2 parents 21fdf54 + de961ed commit 864bb2c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"selector-class-pattern": null,
"selector-max-id": null,
"selector-not-notation": "complex",
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": ["global", "local"]
}
],
"selector-type-no-unknown": null,
"plugin/no-unsupported-browser-features": null,
"wikimedia/no-at-import-css": null,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "awesome-gadgets",
"version": "4.3.1",
"version": "4.3.4",
"description": "Storage, management, compilation, and automatic deployment of MediaWiki gadgets.",
"type": "module",
"scripts": {
Expand Down
44 changes: 24 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions scripts/modules/build-esbuild_options.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import {type BuildOptions, type Plugin} from 'esbuild';
import {type Targets, browserslistToTargets} from 'lightningcss';
import CssModulesPlugin from 'esbuild-css-modules-plugin';
// @ts-expect-error TS7016
import LessPluginNpmImport from 'less-plugin-npm-import';
// @ts-expect-error TS7016
import LessPluginPresetEnv from 'less-plugin-preset-env';
import {SOURCE_MAP} from '../constant';
import browserslist from 'browserslist';
import {lessLoader} from 'esbuild-plugin-less';
import postcss from 'esbuild-postcss';
import esbuildPluginCssModules from 'esbuild-css-modules-plugin';
import {lessLoader as esbuildPluginLess} from 'esbuild-plugin-less';
import esbuildPluginPostcss from 'esbuild-postcss';
import esbuildPluginVue from 'esbuild-plugin-vue3';
import postcssLoadConfig from 'postcss-load-config';
import vuePlugin from 'esbuild-plugin-vue3';

/**
* @summary Do not forget to declare these file extensions in `src/global.d.ts`
Expand All @@ -29,7 +29,7 @@ const loader = {
const lessOptions: Less.Options = {
plugins: [new LessPluginPresetEnv() as unknown as Less.Plugin, new LessPluginNpmImport() as unknown as Less.Plugin],
};
const postcssConfig = await postcssLoadConfig();
const postcssConfig: postcssLoadConfig.Result = await postcssLoadConfig();
const targets: Targets = browserslistToTargets(browserslist());

/**
Expand All @@ -45,18 +45,18 @@ const esbuildOptions = {
format: 'cjs',
legalComments: 'inline',
plugins: [
vuePlugin({
esbuildPluginVue({
enableDevTools: false,
postcss: postcssConfig,
preprocessorOptions: lessOptions,
}) as unknown as Plugin,
CssModulesPlugin({
esbuildPluginCssModules({
targets,
filter: /\.module\.(?:css|less)$/i,
namedExports: true,
}),
postcss(),
lessLoader(lessOptions),
esbuildPluginPostcss(),
esbuildPluginLess(lessOptions),
],
sourcemap: SOURCE_MAP ? 'inline' : false,
treeShaking: true,
Expand Down
13 changes: 8 additions & 5 deletions scripts/modules/utils/deploy-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ const generateTargets = (): DeploymentTargets => {
}
}

for (const [gadgetName, {files}] of Object.entries(targets)) {
if (!files.length) {
delete targets[gadgetName];
}
}

if (!Object.keys(targets).length) {
console.log(chalk.yellow('━ No gadget need to deploy'));
return {};
Expand Down Expand Up @@ -312,11 +318,8 @@ const loadConfig = (): typeof credentials => {
logError('broken');
}

if (
!isMissing &&
(!Object.keys(credentials).length ||
!Object.keys(credentials[Object.keys(credentials)[0] as string] as Partial<Credentials>).length)
) {
const sites: string[] = Object.keys(credentials);
if (!isMissing && (!sites.length || !Object.keys(credentials[sites[0] as string] as Partial<Credentials>).length)) {
logError('empty');
}

Expand Down
9 changes: 6 additions & 3 deletions scripts/modules/utils/general-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ const sortObject = <T extends object>(object: T, isSortArray?: boolean): T => {
natural: true,
})
)) {
const key = _key as keyof T;
const value = object[key];
type Key = keyof T;
type Value = T[Key];

const key = _key as Key;
const value: Value = object[key];

objectSorted[key] =
isSortArray && Array.isArray(value)
Expand All @@ -92,7 +95,7 @@ const sortObject = <T extends object>(object: T, isSortArray?: boolean): T => {
caseInsensitive: true,
natural: true,
})
) as typeof value)
) as Value)
: value;
}

Expand Down

0 comments on commit 864bb2c

Please sign in to comment.