Skip to content

Commit

Permalink
Remove node-emoji dependency (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Nov 20, 2023
1 parent d787d50 commit 1946b74
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-shoes-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Remove `node-emoji` dependency
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ const didYouMean = require('didyoumean2').default;
const validator = new Validator();

const exitWithErrors = async (errors) => {
const { emojify } = await import('node-emoji');

console.log(bold(underline(red('SkuWebpackPlugin: Invalid options'))));
errors.forEach((error) => {
console.log(yellow(emojify(error)));
console.log(yellow(error));
});
process.exit(1);
};
Expand Down Expand Up @@ -85,16 +83,16 @@ module.exports = (options) => {
const suggestedMessage = suggestedKey
? ` Did you mean '${bold(suggestedKey)}'?`
: '';
errors.push(`:question: ${unknownMessage}${suggestedMessage}`);
errors.push(` ${unknownMessage}${suggestedMessage}`);
});

// Validate schema types
const schemaCheckResult = validate(options);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(({ message, field }) => {
const errorMessage = message
? `:no_entry_sign: ${message.replace(field, `${bold(field)}`)}`
: `:no_entry_sign: '${bold(field)}' is invalid`;
? `🚫 ${message.replace(field, `${bold(field)}`)}`
: `🚫 '${bold(field)}' is invalid`;

errors.push(errorMessage);
});
Expand All @@ -106,7 +104,7 @@ module.exports = (options) => {
browserslist(options.browserslist);
} catch (e) {
errors.push(
`:no_entry_sign: '${bold(
`🚫 '${bold(
'browserslist',
)}' must be a valid browserslist query. ${white(e.message)}`,
);
Expand Down
18 changes: 7 additions & 11 deletions packages/sku/context/validateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ const defaultClientEntry = require('./defaultClientEntry');
const availableConfigKeys = Object.keys(defaultSkuConfig);

const exitWithErrors = async (errors) => {
const { emojify } = await import('node-emoji');

console.log(bold(underline(red('Errors in sku config:'))));
errors.forEach((error) => {
console.log(yellow(emojify(error)));
console.log(yellow(error));
});
process.exit(1);
};
Expand All @@ -30,16 +28,16 @@ module.exports = (skuConfig) => {
const suggestedMessage = suggestedKey
? ` Did you mean '${bold(suggestedKey)}'?`
: '';
errors.push(`:question: ${unknownMessage}${suggestedMessage}`);
errors.push(` ${unknownMessage}${suggestedMessage}`);
});

// Validate schema types
const schemaCheckResult = configSchema(skuConfig);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(({ message, field }) => {
const errorMessage = message
? `:no_entry_sign: ${message.replace(field, `${bold(field)}`)}`
: `:no_entry_sign: '${bold(field)}' is invalid`;
? `🚫 ${message.replace(field, `${bold(field)}`)}`
: `🚫 '${bold(field)}' is invalid`;

errors.push(errorMessage);
});
Expand All @@ -48,9 +46,7 @@ module.exports = (skuConfig) => {
// Validate library entry has corresponding libraryName
if (skuConfig.libraryEntry && !skuConfig.libraryName) {
errors.push(
`:no_entry_sign: '${bold(
'libraryEntry',
)}' must have a corresponding '${bold(
`🚫 '${bold('libraryEntry')}' must have a corresponding '${bold(
'libraryName',
)}' option. More details: ${underline(
'https://github.com/seek-oss/sku#building-a-library',
Expand All @@ -62,7 +58,7 @@ module.exports = (skuConfig) => {
skuConfig.routes.forEach(({ name }) => {
if (name === defaultClientEntry) {
errors.push(
`:no_entry_sign: Invalid route name: '${bold(
`🚫 Invalid route name: '${bold(
defaultClientEntry,
)}', please use a different route name`,
);
Expand All @@ -74,7 +70,7 @@ module.exports = (skuConfig) => {
browserslist(skuConfig.supportedBrowsers);
} catch (e) {
errors.push(
`:no_entry_sign: '${bold(
`🚫 '${bold(
'supportedBrowsers',
)}' must be a valid browserslist query. ${white(e.message)}`,
);
Expand Down
1 change: 0 additions & 1 deletion packages/sku/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"lint-staged": "^11.1.1",
"memoizee": "^0.4.15",
"mini-css-extract-plugin": "^2.6.1",
"node-emoji": "^2.1.0",
"node-html-parser": "^6.1.1",
"open": "^7.3.1",
"path-to-regexp": "^6.2.0",
Expand Down
33 changes: 0 additions & 33 deletions pnpm-lock.yaml

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

0 comments on commit 1946b74

Please sign in to comment.