Skip to content

Commit ca2f366

Browse files
Remove redundant prism- prefix from plugin names (#4004)
Now, it’s aligned with language and theme names. - Adjust other plugins' imports and docs, scripts, test helpers, and `components.json` accordingly - Add the corresponding export rule to `package.json` - In most cases, it's a simple file rename
1 parent b6a6687 commit ca2f366

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+78
-78
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"import": "./dist/languages/*.js",
2323
"require": "./dist/cjs/languages/*.js"
2424
},
25+
"./plugins/*": {
26+
"types": "./types/plugins/*.d.ts",
27+
"import": "./dist/plugins/*.js",
28+
"require": "./dist/cjs/plugins/*.js"
29+
},
2530
"./themes/*": "./dist/themes/*.css",
2631
"./components.json": "./dist/components.json"
2732
},

scripts/build.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const themeIds = fs
4141
async function loadComponent (id) {
4242
let file;
4343
if (pluginIds.includes(id)) {
44-
file = path.join(SRC_DIR, `plugins/${id}/prism-${id}.js`);
44+
file = path.join(SRC_DIR, `plugins/${id}/${id}.js`);
4545
}
4646
else {
4747
file = path.join(SRC_DIR, `languages/${id}.js`);
@@ -58,9 +58,9 @@ async function minifyCSS () {
5858
}
5959

6060
for (const id of pluginIds) {
61-
const file = path.join(SRC_DIR, `plugins/${id}/prism-${id}.css`);
61+
const file = path.join(SRC_DIR, `plugins/${id}/${id}.css`);
6262
if (fs.existsSync(file)) {
63-
input[`plugins/prism-${id}.css`] = file;
63+
input[`plugins/${id}.css`] = file;
6464
}
6565
}
6666

@@ -136,7 +136,7 @@ async function treeviewIconFont () {
136136
}
137137
`.trim();
138138

139-
const cssPath = 'src/plugins/treeview-icons/prism-treeview-icons.css';
139+
const cssPath = 'src/plugins/treeview-icons/treeview-icons.css';
140140
const fontFaceRegex =
141141
/\/\*\s*@GENERATED-FONT\s*\*\/\s*@font-face\s*\{(?:[^{}/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\}/;
142142

@@ -391,7 +391,7 @@ async function buildJS () {
391391
input[`languages/${id}`] = path.join(SRC_DIR, `languages/${id}.js`);
392392
}
393393
for (const id of pluginIds) {
394-
input[`plugins/prism-${id}`] = path.join(SRC_DIR, `plugins/${id}/prism-${id}.js`);
394+
input[`plugins/${id}`] = path.join(SRC_DIR, `plugins/${id}/${id}.js`);
395395
}
396396

397397
/** @type {RollupOptions} */
@@ -488,11 +488,7 @@ async function calculateFileSizes () {
488488
continue;
489489
}
490490

491-
const filePath = path.join(
492-
DIST_DIR,
493-
category,
494-
category === 'plugins' ? `prism-${id}` : id
495-
);
491+
const filePath = path.join(DIST_DIR, category, id);
496492
ret[category][id][ext] = await getFileSize(`${filePath}.${ext}`);
497493
}
498494
}

scripts/create-changelog.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ runTask(async () => {
165165
*/
166166
function notPartlyGenerated (change) {
167167
return (
168-
change.file !== 'plugins/autoloader/prism-autoloader.js' &&
169-
change.file !== 'plugins/show-language/prism-show-language.js'
168+
change.file !== 'plugins/autoloader/autoloader.js' &&
169+
change.file !== 'plugins/show-language/show-language.js'
170170
);
171171
}
172172

@@ -260,8 +260,8 @@ runTask(async () => {
260260
// now, only the newly added JS should be left
261261
if (relevantChanges.length === 1) {
262262
const change = relevantChanges[0];
263-
if (change.mode === 'A' && change.file.startsWith('components/prism-')) {
264-
const lang = change.file.match(/prism-([\w-]+)\.js$/)[1];
263+
if (change.mode === 'A' && change.file.startsWith('components/')) {
264+
const lang = change.file.match(/([\w-]+)\.js$/)[1];
265265
const entry = languages[lang] || {
266266
title: 'REMOVED LANGUAGE ' + lang,
267267
};
@@ -293,8 +293,8 @@ runTask(async () => {
293293

294294
if (relevantChanges.length === 1) {
295295
const change = relevantChanges[0];
296-
if (change.mode === 'M' && change.file.startsWith('components/prism-')) {
297-
const lang = change.file.match(/prism-([\w-]+)\.js$/)[1];
296+
if (change.mode === 'M' && change.file.startsWith('components/')) {
297+
const lang = change.file.match(/([\w-]+)\.js$/)[1];
298298
if (lang === 'core') {
299299
addEntry('Other >> Core', removeMessagePrefix('Core', info));
300300
}
@@ -321,7 +321,7 @@ runTask(async () => {
321321
) {
322322
if (relevantChanges.length === 1) {
323323
const change = relevantChanges[0];
324-
const id = change.file.match(/\/prism-([\w-]+)\.js/)[1];
324+
const id = change.file.match(/\/([\w-]+)\.js/)[1];
325325
const title = plugins[id].title;
326326
addEntry('Updated plugins >> ' + title, removeMessagePrefix(title, info));
327327
}
@@ -341,7 +341,7 @@ runTask(async () => {
341341
) {
342342
if (info.changes.length === 1) {
343343
const change = info.changes[0];
344-
let name = (change.file.match(/prism-(\w+)\.css$/) || [, 'Default'])[1];
344+
let name = (change.file.match(/(\w+)\.css$/) || [, 'Default'])[1];
345345
name = name[0].toUpperCase() + name.substr(1);
346346
addEntry('Updated themes >> ' + name, removeMessagePrefix(name, info));
347347
}

src/auto-start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Prism from './global.js';
2-
import autoloader from './plugins/autoloader/prism-autoloader.js';
2+
import autoloader from './plugins/autoloader/autoloader.js';
33
import { documentReady } from './util/async.js';
44

55
Prism.components.add(autoloader);

src/components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@
13311331
},
13321332
"plugins": {
13331333
"meta": {
1334-
"path": "plugins/{id}/prism-{id}",
1334+
"path": "plugins/{id}/{id}",
13351335
"link": "plugins/{id}/"
13361336
},
13371337
"line-highlight": {
File renamed without changes.

src/plugins/autoloader/prism-autoloader.js renamed to src/plugins/autoloader/autoloader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function getDefaultSrcPath () {
88
const script = /** @type {HTMLScriptElement | null} */ (document.currentScript);
99
if (script) {
1010
const autoloaderFile =
11-
/\bplugins\/autoloader\/prism-autoloader\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i;
11+
/\bplugins\/autoloader\/autoloader\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i;
1212
const prismFile = /(^|\/)[\w-]+\.(?:min\.)?m?js(?:\?[^\r\n/]*)?$/i;
1313

1414
const autoloaderPath = script.getAttribute('data-autoloader-path');

0 commit comments

Comments
 (0)