Skip to content

Commit

Permalink
Merge pull request #95 from assetgraph/depfu/update/npm/prettier-3.0.0
Browse files Browse the repository at this point in the history
Update prettier → 3.0.0 (unknown)
  • Loading branch information
papandreou authored Jul 9, 2023
2 parents 2ef5ec9 + 1f238e8 commit 6460d2a
Show file tree
Hide file tree
Showing 18 changed files with 387 additions and 356 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Tests

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
name: Node ${{ matrix.node }}
strategy:
matrix:
Expand All @@ -23,7 +23,7 @@ jobs:
- run: npm test

test-targets:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
name: ${{ matrix.targets.name }}
strategy:
matrix:
Expand Down
52 changes: 26 additions & 26 deletions bin/applyBabelJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const urlTools = require('urltools');

const commandLineOptions = require('optimist')
.usage(
'$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...'
'$0 --i18n <pathToI18nFile> [--locales <localeId>[,<localeId>...]] [--defaultlocale <localeId>] --babeldir=<dirContainingTheBabelFilesToApply> --root <inputRootDirectory> <htmlFile>...',
)
.options('defaultlocale', {
describe:
Expand All @@ -33,8 +33,8 @@ const localeIds =
commandLineOptions.locales &&
_.flatten(
_.flatten([commandLineOptions.locales]).map((localeId) =>
localeId.split(',')
)
localeId.split(','),
),
).map(i18nTools.normalizeLocaleId);

const initialAssetUrls = commandLineOptions._.map(urlTools.fsFilePathToFileUrl);
Expand All @@ -44,13 +44,13 @@ let i18nUrl;

if (commandLineOptions.defaultlocale) {
defaultLocaleId = i18nTools.normalizeLocaleId(
commandLineOptions.defaultlocale
commandLineOptions.defaultlocale,
);
if (localeIds && localeIds.indexOf(defaultLocaleId) === -1) {
throw new Error(
`The default locale id (${defaultLocaleId}) is not among the locales listed with the --locales switch (${localeIds.join(
', '
)})`
', ',
)})`,
);
}
} else if (localeIds) {
Expand Down Expand Up @@ -108,7 +108,7 @@ if (commandLineOptions.i18n) {

const occurrencesByKey = i18nTools.findOccurrences(
assetGraph,
assetGraph.findAssets({ type: 'Html', isInitial: true })
assetGraph.findAssets({ type: 'Html', isInitial: true }),
);

let i18nAssetForAllKeys;
Expand All @@ -124,7 +124,7 @@ if (commandLineOptions.i18n) {
assetGraph.addAsset(i18nAssetForAllKeys);
assetGraph.emit(
'info',
`--i18n ${commandLineOptions.i18n} not found, creating it`
`--i18n ${commandLineOptions.i18n} not found, creating it`,
);
} else if (!i18nAssetForAllKeys.isLoaded) {
i18nAssetForAllKeys.parseTree = {};
Expand All @@ -143,14 +143,14 @@ if (commandLineOptions.i18n) {

const babelBody = fs.readFileSync(
path.resolve(commandLineOptions.babeldir, fileName),
'utf-8'
'utf-8',
);

isSeenByLocaleId[localeId] = true;

if (localeIds && localeIds.indexOf(localeId) === -1) {
console.warn(
`Skipping ${fileName} because ${localeId} was not mentioned in --locales`
`Skipping ${fileName} because ${localeId} was not mentioned in --locales`,
);
return;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ if (commandLineOptions.i18n) {
throw new Error(
`Error: Expected ${JSON.stringify(cursor)}['${
path[0]
}'] to be undefined or an array while processing line ${lineNumber} of ${fileName}:\n${line}`
}'] to be undefined or an array while processing line ${lineNumber} of ${fileName}:\n${line}`,
);
}
} else {
Expand All @@ -206,30 +206,30 @@ if (commandLineOptions.i18n) {
throw new Error(
`Error: Expected ${JSON.stringify(cursor)}['${
path[0]
}'] to be undefined or an object while processing line ${lineNumber} of ${fileName}:\n${line}`
}'] to be undefined or an object while processing line ${lineNumber} of ${fileName}:\n${line}`,
);
}
}
cursor = cursor[path.shift()];
}
if (path[0] in cursor) {
throw new Error(
`Error: Found double declaration of key in line ${lineNumber} of ${fileName}:\n${line}`
`Error: Found double declaration of key in line ${lineNumber} of ${fileName}:\n${line}`,
);
}
cursor[path[0]] = value;
} else {
console.warn(
`Couldn't parse line ${
lineNumber + 1
} of the ${localeId} file: ${line}`
} of the ${localeId} file: ${line}`,
);
}
}
});
} else {
console.warn(
`Skipping file whose basename does not look like a locale id: ${fileName}`
`Skipping file whose basename does not look like a locale id: ${fileName}`,
);
}
}
Expand All @@ -238,7 +238,7 @@ if (commandLineOptions.i18n) {
localeIds.forEach((localeId) => {
if (!isSeenByLocaleId[localeId]) {
console.warn(
`${localeId}.txt was not found although --locales ${localeId} was specified`
`${localeId}.txt was not found although --locales ${localeId} was specified`,
);
}
});
Expand Down Expand Up @@ -266,7 +266,7 @@ if (commandLineOptions.i18n) {
keys.every(
(key) =>
['zero', 'one', 'two', 'few', 'many', 'other'].indexOf(key) !==
-1
-1,
)
) {
keys = [];
Expand All @@ -279,7 +279,7 @@ if (commandLineOptions.i18n) {
`${key}: Discarding plural forms not used in ${localeId}:`,
obj,
'=>',
coalescedObj
coalescedObj,
);
}
obj = coalescedObj;
Expand Down Expand Up @@ -336,8 +336,8 @@ if (commandLineOptions.i18n) {
_.merge(
Array.isArray(newTranslation) ? [] : {},
existingTranslation,
newTranslation
)
newTranslation,
),
);
} else if (
typeof existingTranslation === 'undefined' ||
Expand Down Expand Up @@ -404,7 +404,7 @@ if (commandLineOptions.i18n) {
if (
!_.isEqual(
occurrence.defaultValue,
allKeysInDefaultLocale[occurrence.key]
allKeysInDefaultLocale[occurrence.key],
)
) {
if (occurrence.type === 'TR' || occurrence.type === 'TRPAT') {
Expand All @@ -413,9 +413,9 @@ if (commandLineOptions.i18n) {
const replaceRegExp = new RegExp(
`(TR(?:PAT)?\\((['"])${key.replace(
/[.[\]*+?{}()^$]/g,
'\\$&'
'\\$&',
)}\\2\\s*,\\s*)(?:[^)'"]*|"[^"]*"|'[^']*')*?\\)`,
'g'
'g',
);

replacedTextByAssetId[asset.id] = (
Expand All @@ -425,8 +425,8 @@ if (commandLineOptions.i18n) {
).replace(
replaceRegExp,
`$1${util.inspect(
translationsByKeyAndLocaleId[key][defaultLocaleId]
)})`
translationsByKeyAndLocaleId[key][defaultLocaleId],
)})`,
);
}
}
Expand All @@ -446,7 +446,7 @@ if (commandLineOptions.i18n) {
$0
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&')
.replace(/&amp;/g, '&'),
);
}
asset._rawSrc = replacedText.toString('utf-8');
Expand Down
26 changes: 13 additions & 13 deletions bin/checkLanguageKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const localeIds =
commandLineOptions.locales &&
_.flatten(
_.flatten([commandLineOptions.locales]).map((localeId) =>
localeId.split(',')
)
localeId.split(','),
),
).map(i18nTools.normalizeLocaleId);

const defaultLocaleId =
Expand All @@ -68,43 +68,43 @@ const ignoreMessageTypes =
commandLineOptions.ignore &&
_.flatten(
_.flatten([commandLineOptions.ignore]).map((ignoreMessageType) =>
ignoreMessageType.split(',')
)
ignoreMessageType.split(','),
),
);

const warnMessageTypes =
commandLineOptions.warn &&
_.flatten(
_.flatten([commandLineOptions.warn]).map((warnMessageType) =>
warnMessageType.split(',')
)
warnMessageType.split(','),
),
);

const includeAttributeNames =
commandLineOptions.includeattribute &&
_.flatten(
_.flatten([commandLineOptions.includeattribute]).map((attributeName) =>
attributeName.split(',')
)
attributeName.split(','),
),
);

const excludeAttributeNames =
commandLineOptions.excludeattribute &&
_.flatten(
_.flatten([commandLineOptions.excludeattribute]).map((attributeName) =>
attributeName.split(',')
)
attributeName.split(','),
),
);

let inputUrls;

if (commandLineOptions._.length > 0) {
inputUrls = commandLineOptions._.map((urlOrFsPath) =>
urlTools.urlOrFsPathToUrl(urlOrFsPath, false)
urlTools.urlOrFsPathToUrl(urlOrFsPath, false),
);
if (!rootUrl) {
rootUrl = urlTools.findCommonUrlPrefix(
inputUrls.filter((inputUrl) => /^file:/.test(inputUrl))
inputUrls.filter((inputUrl) => /^file:/.test(inputUrl)),
);
if (rootUrl) {
console.warn(`Guessing --root from input files: ${rootUrl}`);
Expand All @@ -115,7 +115,7 @@ if (commandLineOptions._.length > 0) {
console.warn(`No input files specified, defaulting to ${inputUrls[0]}`);
} else {
throw new Error(
"No input files and no --root specified (or it isn't file:), cannot proceed"
"No input files and no --root specified (or it isn't file:), cannot proceed",
);
}

Expand Down
Loading

0 comments on commit 6460d2a

Please sign in to comment.