Skip to content

Commit

Permalink
Upgraded plugin for Strapi 4.20 and NodeJS 20
Browse files Browse the repository at this point in the history
  • Loading branch information
BirknerAlex committed Mar 19, 2024
1 parent 7706625 commit 72807b6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
14 changes: 9 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
},
"devDependencies": {},
"dependencies": {
"@strapi/plugin-i18n": "4.11.7",
"@strapi/plugin-users-permissions": "4.11.7",
"@strapi/strapi": "4.11.7",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "5.3.4",
"@strapi/plugin-i18n": "4.20.4",
"@strapi/plugin-users-permissions": "4.20.4",
"@strapi/strapi": "4.20.4",
"better-sqlite3": "8.0.1",
"strapi-plugin-image-optimizer": "../"
"strapi-plugin-image-optimizer": "link:../",
"styled-components": "^5.2.1"
},
"author": {
"name": "A Strapi developer"
Expand All @@ -24,7 +28,7 @@
"uuid": "33f536a8-ba40-4664-bfb2-d50d6ab5abc8"
},
"engines": {
"node": ">=14.19.1 <=18.x.x",
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
Expand Down
3 changes: 2 additions & 1 deletion example/src/extensions/upload/strapi-server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import imageOptimizerService from "strapi-plugin-image-optimizer/dist/server/services/image-optimizer-service";
import { LoadedPlugin } from "@strapi/types/dist/types/core/plugins";

module.exports = (plugin) => {
module.exports = (plugin: LoadedPlugin) => {
plugin.services["image-manipulation"] = imageOptimizerService;
return plugin;
};
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-image-optimizer",
"version": "2.1.1",
"version": "2.2.0",
"description": "Optimize your images for desktop, tablet and mobile and different image formats.",
"homepage": "https://github.com/marlokessler/strapi-plugin-image-optimizer#readme",
"license": "MIT",
Expand Down Expand Up @@ -47,18 +47,19 @@
]
},
"engines": {
"node": ">=14.19.1 <=18.x.x",
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"devDependencies": {
"@strapi/typescript-utils": "^4.11.7",
"@strapi/typescript-utils": "^4.20.5",
"install-peers": "^1.0.4",
"typescript": "^5.0.4"
"typescript": "^5.4.2"
},
"peerDependencies": {
"@strapi/strapi": "^4.11.7",
"@strapi/utils": "^4.11.7",
"yup": "^1.1.1"
"@strapi/core": "*",
"@strapi/strapi": "^4.20.5",
"@strapi/utils": "^4.20.5",
"yup": "^1.4.0"
},
"scripts": {
"add:apple_arm": "npm_config_build_from_source=true yarn add",
Expand Down
8 changes: 5 additions & 3 deletions server/services/image-optimizer-service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ReadStream, createReadStream, createWriteStream } from "fs";
import { join } from "path";
import sharp, { Sharp, Metadata } from "sharp";
import { file as fileUtils } from '@strapi/utils';

import { bytesToKbytes } from "@strapi/utils/dist/file";
import imageManipulation from "@strapi/plugin-upload/server/services/image-manipulation";
// @ts-ignore - No types available
import pluginUpload from "@strapi/plugin-upload/strapi-server";
const imageManipulation = pluginUpload().services["image-manipulation"];

import {
OutputFormat,
Expand Down Expand Up @@ -113,7 +115,7 @@ async function resizeFileTo(
path: sourceFile.path,
width: metadata.width,
height: metadata.height,
size: metadata.size && bytesToKbytes(metadata.size),
size: metadata.size && fileUtils.bytesToKbytes(metadata.size),
getStream: () => createReadStream(filePath),
};
}
Expand Down
2 changes: 1 addition & 1 deletion server/services/settings-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {} from "@strapi/strapi";
import { Config } from "../models/config";
import { Config } from "../models";
import pluginId from "../utils/pluginId";

class SettingsService {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"declaration": true
"declaration": true,
},
"include": [
// Include the root directory
Expand Down

0 comments on commit 72807b6

Please sign in to comment.