Skip to content

Commit

Permalink
v1.1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
dakln committed Oct 17, 2024
1 parent c1de7e2 commit a456ecc
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Colors } from "./deps.ts";
import { buildAddon } from "./cli/main.ts";
import type { AddonType } from "./lib/common.ts";

const VERSION = '1.1.13'
const VERSION = '1.1.14'

type LostCommand = 'none' | 'help' | 'version' | 'build' | 'create' | 'serve';

Expand Down
7 changes: 5 additions & 2 deletions cli/get-addon-files.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { LostConfig, FileDependencyType } from "../lib/common.ts";
import { LOGGER } from "./misc.ts";
import { getMIMEFileType, LOGGER } from "./misc.ts";
import { ADDON_FILES_FOLDER_PATH } from "./paths.ts";

export interface AddonFile {
filename: string;
fileType?: string;
path: string;
dependencyType: FileDependencyType;
}
Expand All @@ -25,10 +26,12 @@ export async function getAddonFiles(config: LostConfig<'plugin' | 'behavior'>) {
} else {
LOGGER.Info(`Founded file: ${entry.name}`, `Loading with default type: ${(entry.name.endsWith('.css')) ? 'external-css' : 'copy-to-output'}`);
}
const dependencyType = (fileInConfig) ? fileInConfig.Type : (entry.name.endsWith('.css')) ? 'external-css' : 'copy-to-output';
files.push({
filename: entry.name,
fileType: (dependencyType === 'copy-to-output') ? getMIMEFileType(entry.name) : undefined,
path: `${path}/${entry.name}`,
dependencyType: (fileInConfig) ? fileInConfig.Type : (entry.name.endsWith('.css')) ? 'external-css' : 'copy-to-output'
dependencyType: dependencyType
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions cli/get-addon-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ADDON_SCRIPTS_FOLDER_PATH } from "./paths.ts";

export interface AddonScript {
filename: string;
scriptType?: 'module';
path: string;
dependencyType: ScriptDependencyType;
}
Expand All @@ -27,6 +28,7 @@ export async function getAddonScripts(config: LostConfig<'plugin' | 'behavior'>)
}
scripts.push({
filename: entry.name,
scriptType: (scriptInConfig && scriptInConfig.Type === 'external-dom-script' && scriptInConfig.ScriptType) ? scriptInConfig.ScriptType : undefined,
path: `${path}/${entry.name}`,
dependencyType: (scriptInConfig) ? scriptInConfig.Type : 'external-dom-script'
})
Expand Down
3 changes: 2 additions & 1 deletion cli/misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { LOGGER } from "./misc/logger.ts";
export { ErrorMessage, WarningMessage } from "./misc/errors.ts";
export { getModule } from "./misc/get-module.ts";
export { findDuplicatesInArray } from "./misc/find-duplicates.ts";
export { findDuplicatesInArray } from "./misc/find-duplicates.ts";
export { getMIMEFileType } from "./misc/get-mime-file-type.ts";
138 changes: 138 additions & 0 deletions cli/misc/get-mime-file-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
export type FileMIMEType =
| 'application/json'
| 'application/javascript'
| 'application/pdf'
| 'application/xml'
| 'application/zip'
| 'application/x-www-form-urlencoded'
| 'application/vnd.ms-excel'
| 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
| 'application/vnd.ms-powerpoint'
| 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
| 'application/msword'
| 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
| 'audio/mpeg'
| 'audio/wav'
| 'audio/ogg'
| 'audio/webm'
| 'image/jpeg'
| 'image/png'
| 'image/gif'
| 'image/bmp'
| 'image/webp'
| 'image/svg+xml'
| 'text/plain'
| 'text/html'
| 'text/css'
| 'text/javascript'
| 'text/csv'
| 'text/xml'
| 'video/mp4'
| 'video/mpeg'
| 'video/ogg'
| 'video/webm'
| 'video/quicktime';

export function getMIMEFileType(filename: string): FileMIMEType | undefined {
if (filename.endsWith('.json')) {
return 'application/json';
}
if (filename.endsWith('.js')) {
return 'application/javascript';
}
if (filename.endsWith('.pdf')) {
return 'application/pdf';
}
if (filename.endsWith('.xml')) {
return 'application/xml';
}
if (filename.endsWith('.zip')) {
return 'application/zip';
}
if (filename.endsWith('.urlencoded')) {
return 'application/x-www-form-urlencoded';
}
if (filename.endsWith('.xls')) {
return 'application/vnd.ms-excel';
}
if (filename.endsWith('.xlsx')) {
return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
}
if (filename.endsWith('.ppt')) {
return 'application/vnd.ms-powerpoint';
}
if (filename.endsWith('.pptx')) {
return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
}
if (filename.endsWith('.doc')) {
return 'application/msword';
}
if (filename.endsWith('.docx')) {
return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
}
if (filename.endsWith('.mp3')) {
return 'audio/mpeg';
}
if (filename.endsWith('.wav')) {
return 'audio/wav';
}
if (filename.endsWith('.ogg')) {
return 'audio/ogg';
}
if (filename.endsWith('.webm')) {
return 'audio/webm';
}
if (filename.endsWith('.jpg') || filename.endsWith('.jpeg')) {
return 'image/jpeg';
}
if (filename.endsWith('.png')) {
return 'image/png';
}
if (filename.endsWith('.gif')) {
return 'image/gif';
}
if (filename.endsWith('.bmp')) {
return 'image/bmp';
}
if (filename.endsWith('.webp')) {
return 'image/webp';
}
if (filename.endsWith('.svg')) {
return 'image/svg+xml';
}
if (filename.endsWith('.txt')) {
return 'text/plain';
}
if (filename.endsWith('.html') || filename.endsWith('.htm')) {
return 'text/html';
}
if (filename.endsWith('.css')) {
return 'text/css';
}
if (filename.endsWith('.mjs')) {
return 'text/javascript';
}
if (filename.endsWith('.csv')) {
return 'text/csv';
}
if (filename.endsWith('.xml')) {
return 'text/xml';
}
if (filename.endsWith('.mp4')) {
return 'video/mp4';
}
if (filename.endsWith('.mpeg')) {
return 'video/mpeg';
}
if (filename.endsWith('.ogv')) {
return 'video/ogg';
}
if (filename.endsWith('.webm')) {
return 'video/webm';
}
if (filename.endsWith('.mov')) {
return 'video/quicktime';
}
// Если расширение не найдено, возвращаем undefined
return undefined;
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lost-c3/lib",
"version": "1.1.13",
"version": "1.1.14",
"exports": {
".": "./mod.ts",
"./cli": "./cli.ts"
Expand Down

0 comments on commit a456ecc

Please sign in to comment.