Skip to content

Commit

Permalink
style: format code with Prettier and StandardJS
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 377e9fc according to the output
from Prettier and StandardJS.

Details: #155
  • Loading branch information
deepsource-autofix[bot] authored Jan 4, 2024
1 parent 77402e7 commit 3c15e2c
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 254 deletions.
25 changes: 12 additions & 13 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Importing env files here to validate on build
import "./src/env.mjs";
import './src/env.mjs'
import withBundleAnalyzer from '@next/bundle-analyzer'
import pkg from './next-i18next.config.js'
import withPWAInit from "@ducanh2912/next-pwa";
import {withAxiom} from "next-axiom";
import withPWAInit from '@ducanh2912/next-pwa'
import { withAxiom } from 'next-axiom'

const withPWA = withPWAInit({
dest: 'public',
fallbacks: {
document: '/_offline',
document: '/_offline'
}
});
})

const { i18n } = pkg

Expand All @@ -25,16 +25,15 @@ const withMyBundleAnalyzer = withBundleAnalyzer({
*/
!process.env.SKIP_ENV_VALIDATION && (await import('./src/env.mjs'))


/** @type {import("next").NextConfig} */
const config = withMyBundleAnalyzer(withPWA(
withAxiom({
reactStrictMode: true,
withAxiom({
reactStrictMode: true,

/** Enables hot reloading for local packages without a build step */
transpilePackages: ["@weatherio/api", "@weatherio/ui", "@weatherio/types"],
i18n,
}))
/** Enables hot reloading for local packages without a build step */
transpilePackages: ['@weatherio/api', '@weatherio/ui', '@weatherio/types'],
i18n
}))
)

export default config;
export default config
6 changes: 3 additions & 3 deletions apps/web/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
autoprefixer: {}
}
}
18 changes: 9 additions & 9 deletions apps/web/src/env.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import {createEnv} from "@t3-oss/env-nextjs";
import {z} from "zod";
import { createEnv } from '@t3-oss/env-nextjs'
import { z } from 'zod'

export const env = createEnv({
shared: {
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
VERCEL_ENV: z.enum(["development", "preview", "production"]).optional(),
.enum(['development', 'production', 'test'])
.default('development'),
VERCEL_ENV: z.enum(['development', 'preview', 'production']).optional(),
VERCEL_URL: z
.string()
.optional()
.transform((v) => (v ? `https://${v}` : undefined)),
PORT: z.coerce.number().default(3000),
PORT: z.coerce.number().default(3000)
},
/**
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
*/
runtimeEnv: {
PORT: process.env.PORT,
VERCEL_URL: process.env.VERCEL_URL,
VERCEL_URL: process.env.VERCEL_URL

// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
skipValidation:
!!process.env.CI ||
!!process.env.SKIP_ENV_VALIDATION ||
process.env.npm_lifecycle_event === "lint",
});
process.env.npm_lifecycle_event === 'lint'
})
16 changes: 8 additions & 8 deletions packages/api/env.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createEnv} from "@t3-oss/env-nextjs";
import {z} from "zod";
import { createEnv } from '@t3-oss/env-nextjs'
import { z } from 'zod'

export const env = createEnv({
server: {
Expand All @@ -11,19 +11,19 @@ export const env = createEnv({
UPSTASH_RATELIMITER_TIME_INTERVAL: z.string().min(1),
RESEND_API_KEY: z.string().min(1),
QWEATHER_API_KEY: z.string().min(1),
API_NINJA_API_KEY: z.string().min(1),
},
API_NINJA_API_KEY: z.string().min(1)
},
client: {},
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
OPEN_WEATHER_API_KEY: process.env.OPEN_WEATHER_API_KEY,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_RATELIMITER_TOKENS_PER_TIME: process.env.UPSTASH_RATELIMITER_TOKENS_PER_TIME,
UPSTASH_RATELIMITER_TIME_INTERVAL: process.env.UPSTASH_RATELIMITER_TIME_INTERVAL,
UPSTASH_RATELIMITER_TIME_INTERVAL: process.env.UPSTASH_RATELIMITER_TIME_INTERVAL,
RESEND_API_KEY: process.env.RESEND_API_KEY,
QWEATHER_API_KEY: process.env.QWEATHER_API_KEY,
API_NINJA_API_KEY: process.env.API_NINJA_API_KEY,
API_NINJA_API_KEY: process.env.API_NINJA_API_KEY
},
skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION,
});
skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION
})
178 changes: 89 additions & 89 deletions packages/city-data/convert.mjs
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
import fs from "fs";
import readline from "readline";
import jsonfile from "jsonfile";
import {z} from "zod";
import {citySchema} from "./renamejsonproperties.mjs";
import fs from 'fs'
import readline from 'readline'
import jsonfile from 'jsonfile'
import { z } from 'zod'
import { citySchema } from './renamejsonproperties.mjs'

export const germanNamesSchema = z.array(
z.object({
geonameid: z.string(),
isolanguage: z.string(),
alternateName: z.string(),
isPreferredName: z.string(),
}),
);
z.object({
geonameid: z.string(),
isolanguage: z.string(),
alternateName: z.string(),
isPreferredName: z.string()
})
)

const removeDoubleQuotes = (/** @type {string} */ value) =>
value.replaceAll('"', "");
value.replaceAll('"', '')

const txtToJson = (
/** @type {string} */ filename,
columnNameMapping = {},
/** @type {jsonfile.Path} */ jsonFilePath,
/** @type {jsonfile.Path} */ jsonFilePath
) => {
return new Promise((resolve, reject) => {
console.log(`Converting ${filename}.txt to ${jsonFilePath}`);
const txtFilePath = `./${filename}.txt`;
jsonFilePath = jsonFilePath || `./${filename}.json`;
// @ts-ignore
let entries = [],
i = 0,
lineValues;
console.log(`Converting ${filename}.txt to ${jsonFilePath}`)
const txtFilePath = `./${filename}.txt`
jsonFilePath = jsonFilePath || `./${filename}.json`
// @ts-ignore
const entries = []
let i = 0
let lineValues
const mappedColumnIndexes = Object.keys(columnNameMapping).map((index) =>
parseInt(index),
);
parseInt(index)
)

readline
.createInterface({
input: fs.createReadStream(txtFilePath),
output: process.stdout,
terminal: false,
terminal: false
})
.on("line", function (line) {
lineValues = line.split("\t");
.on('line', function (line) {
lineValues = line.split('\t')
if (i !== 0) {
entries.push(
lineValues.reduce((entry, value, valueIndex) => {
if (mappedColumnIndexes.includes(valueIndex)) {
// @ts-ignore
// @ts-ignore
entry[columnNameMapping[valueIndex]] =
removeDoubleQuotes(value);
removeDoubleQuotes(value)
}

return entry;
}, {}),
);
return entry
}, {})
)
}
i++;
i++
})
.on("close", function () {
console.log(`Writing ${i} entries to ${jsonFilePath}`);
.on('close', function () {
console.log(`Writing ${i} entries to ${jsonFilePath}`)
jsonfile.writeFile(
jsonFilePath,
// @ts-ignore
// @ts-ignore
entries,
{ spaces: 2 },
function (err) {
if (err) {
console.error(err);
reject(err);
console.error(err)
reject(err)
} else {
resolve(undefined);
resolve(undefined)
}
},
);
});
});
};
}
)
})
})
}

// geonameid : integer id of record in geonames database
// name : name of geographical point (utf8) varchar(200)
Expand All @@ -97,83 +97,83 @@ const txtToJson = (
// modification date : date of last modification in yyyy-MM-dd format
Promise.all([
txtToJson(
"cities1000",
'cities1000',
{
0: "id",
8: "country",
1: "name",
4: "lat",
5: "lng",
10: "admin1",
11: "admin2",
0: 'id',
8: 'country',
1: 'name',
4: 'lat',
5: 'lng',
10: 'admin1',
11: 'admin2'
},
"./cities.json",
'./cities.json'
),

txtToJson(
"admin1CodesASCII",
'admin1CodesASCII',
{
0: "code",
1: "name",
0: 'code',
1: 'name'
},
"./admin1.json",
'./admin1.json'
),

txtToJson(
"admin2Codes",
'admin2Codes',
{
0: "code",
1: "name",
0: 'code',
1: 'name'
},
"./admin2.json",
'./admin2.json'
),

txtToJson(
"DE",
'DE',
{
0: "alternateNameId",
1: "geonameid",
2: "isolanguage",
3: "alternateName",
4: "isPreferredName",
5: "isShortName",
6: "isColloquial",
7: "isHistoric",
8: "from",
9: "to",
0: 'alternateNameId',
1: 'geonameid',
2: 'isolanguage',
3: 'alternateName',
4: 'isPreferredName',
5: 'isShortName',
6: 'isColloquial',
7: 'isHistoric',
8: 'from',
9: 'to'
},
"./DE.json",
),
'./DE.json'
)
]).then(() => {
console.log("Done creating JSON files");
console.log('Done creating JSON files')

console.log("Starting to add German names to cities.json");
console.log('Starting to add German names to cities.json')

const cities = JSON.parse(fs.readFileSync("./cities.json", "utf8"));
const germanNames = JSON.parse(fs.readFileSync("./DE.json", "utf8"));
const parsedCities = citySchema.parse(cities);
const parsedGermanNames = germanNamesSchema.parse(germanNames);
const cities = JSON.parse(fs.readFileSync('./cities.json', 'utf8'))
const germanNames = JSON.parse(fs.readFileSync('./DE.json', 'utf8'))
const parsedCities = citySchema.parse(cities)
const parsedGermanNames = germanNamesSchema.parse(germanNames)

// Add the German names to the cities
parsedCities.forEach((city) => {
const germanNameEntry = parsedGermanNames.find(
(entry) =>
entry.geonameid === city.id &&
entry.isolanguage === "de" &&
entry.isPreferredName === "1",
);
entry.isolanguage === 'de' &&
entry.isPreferredName === '1'
)
if (germanNameEntry) {
// console.debug(germanNameEntry);
const germanCity = {
...city,
name: germanNameEntry.alternateName,
};
parsedCities.push(germanCity);
name: germanNameEntry.alternateName
}
parsedCities.push(germanCity)
}
});
})

// Write the updated cities back to the cities.json file
fs.writeFileSync("./cities.json", JSON.stringify(parsedCities, null, 2), "utf8");
fs.writeFileSync('./cities.json', JSON.stringify(parsedCities, null, 2), 'utf8')

console.log("Done adding German names to cities.json");
});
console.log('Done adding German names to cities.json')
})
Loading

0 comments on commit 3c15e2c

Please sign in to comment.