Skip to content

Commit

Permalink
feat: update sass & typescript (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrohmer authored Jan 28, 2022
1 parent f9d1cce commit f317779
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 42 deletions.
16 changes: 8 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { filterFiles } from "./lib/pipes/filterFiles";
import { PostcssPipeResult } from "./lib/pipes/processPostcss";
import { getErrorCollector } from "./lib/util/error-collector";
import { compileFile, compilerPipe } from "./lib/compilerPipe";
import { Options as SassOptions } from "sass";
import { LegacyOptions as SassOptions } from "sass";
import { writeFile } from "./lib/util/fs-util";

type OutputStyle = "compressed" | "expanded";
Expand All @@ -32,7 +32,7 @@ export interface EntryConfig {
out: string;
postsassConfig: {
postcss: any;
sass: SassOptions;
sass: SassOptions<'sync'>;
};
}

Expand Down Expand Up @@ -94,7 +94,7 @@ export async function compile(params: Params) {
try {
// Wait until all files are processed
await Promise.all(cbs);
} catch (e) {
} catch(e : any) {
console.error(chalk.red(chalk.bold("Error occured:"), e.message));
console.error(e.stack);
process.exitCode = 1;
Expand Down Expand Up @@ -154,7 +154,7 @@ function dataListener(params: Params, entry: EntryConfig) {
// when a file is changed, all its dependants should be updated
// includedFiles includes the entry file as well
function relationTracker(d: PostcssPipeResult) {
d.sassResult.stats.includedFiles.forEach((f) => {
d.sassResult.stats.includedFiles.forEach((f: string) => {
if (!(f in relationships)) {
relationships[f] = [];
relationships[f].push(d.from);
Expand Down Expand Up @@ -191,7 +191,7 @@ async function enableWatchMode(params: Params, entries: EntryConfig[]) {
});
});
return Promise.all(promises);
} catch (e) {
} catch(e : any) {
console.error(e);
return;
}
Expand All @@ -209,7 +209,7 @@ function changeHandler(entry: EntryConfig) {
console.info(
chalk.bold(chalk.blue("Updated file", chalk.magenta(write.from.replace(entry.src, entry.srcRelative))))
);
} catch (e) {
} catch(e : any) {
console.error(chalk.bold.red("Error when compiling", p), e.message);
}
}
Expand All @@ -218,7 +218,7 @@ function changeHandler(entry: EntryConfig) {
}

async function loadConfig(params: Params): Promise<EntryConfig["postsassConfig"]> {
const sassCliConfig = { outputStyle: params.outputStyle, sourceMap: params.sourceMap };
const sassCliConfig = { outputStyle: params.outputStyle, sourceMap: params.sourceMap } as SassOptions<'sync'>;
let fileConfig;
const builder = {
postcss: null,
Expand All @@ -232,7 +232,7 @@ async function loadConfig(params: Params): Promise<EntryConfig["postsassConfig"]
if (typeof fileConfig.sass === "object") {
builder.sass = { ...fileConfig.sass, ...sassCliConfig };
}
} catch (e) {
} catch(e : any) {
console.warn("No postsass config file found");
if (!e.code) {
console.error(e);
Expand Down
2 changes: 1 addition & 1 deletion lib/compilerPipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function compilerPipe(entry: EntryConfig) {
try {
const result = await compileFile(inPath, entry);
this.push(result);
} catch (e) {
} catch(e: any) {
console.error(chalk.red("Error in", item.path));
addError(e);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/pipes/processPostcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EntryConfig } from "../../index";

export interface PostcssPipeResult {
result: PostcssResult;
sassResult: sass.Result;
sassResult: sass.LegacyResult;
from: string;
to: string;
}
Expand All @@ -22,7 +22,7 @@ type PostcssUse = (p: PostcssUseParams) => AcceptedPlugin;
* @param sassResult
* @param entry
*/
export async function processPostcss(sassResult: sass.Result, entry: EntryConfig): Promise<PostcssPipeResult> {
export async function processPostcss(sassResult: sass.LegacyResult, entry: EntryConfig): Promise<PostcssPipeResult> {
const from = sassResult.stats.entry;
const to = from.replace(entry.src, entry.out).replace(/\.(scss|sass)$/, ".css");
const options: PostcssProcessOptions = {
Expand Down
2 changes: 1 addition & 1 deletion lib/pipes/processSass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EntryConfig } from "../../index";
* @param inPath
* @param entry
*/
export async function processSass(inPath: string, entry: EntryConfig): Promise<sass.Result> {
export async function processSass(inPath: string, entry: EntryConfig): Promise<sass.LegacyResult> {
const outFile = inPath.replace(entry.src, entry.out).replace(/\.(scss|sass)$/, ".css");
return sass.renderSync({
...entry.postsassConfig.sass,
Expand Down
2 changes: 1 addition & 1 deletion lib/util/fs-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function writeFile(filepath: string, data: any) {
if (!stat.isDirectory()) {
await fs.mkdir(dir, { recursive: true });
}
} catch (e) {
} catch(e: any) {
if (e.code === "ENOENT") {
await fs.mkdir(dir, { recursive: true });
} else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"chokidar": "^3.4.1",
"klaw": "^3.0.0",
"postcss": "^8.2.0",
"sass": "^1.26.10",
"sass": "1.49.0",
"through2": "^4.0.2",
"yargs": "^15.4.1"
},
Expand All @@ -59,7 +59,7 @@
"husky": "4.2.5",
"prettier": "2.0.5",
"pretty-quick": "2.0.1",
"typescript": "4.1.3"
"typescript": "4.5.5"
},
"husky": {
"hooks": {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// "incremental": true, /* Enable incremental compilation */
"target": "ES2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": ["ES2018"] /* Specify library files to be included in the compilation. */,
"lib": ["ES2018", "dom"] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down Expand Up @@ -61,6 +61,6 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
}
}
82 changes: 57 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ anymatch@~3.1.1:
normalize-path "^3.0.0"
picomatch "^2.0.4"

anymatch@~3.1.2:
version "3.1.2"
resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==
dependencies:
normalize-path "^3.0.0"
picomatch "^2.0.4"

array-differ@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
Expand Down Expand Up @@ -181,20 +189,20 @@ chalk@^4.1.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

"chokidar@>=2.0.0 <4.0.0":
version "3.3.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.1.tgz#c84e5b3d18d9a4d77558fef466b1bf16bbeb3450"
integrity sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg==
"chokidar@>=3.0.0 <4.0.0":
version "3.5.3"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
dependencies:
anymatch "~3.1.1"
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.0"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.3.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.1.2"
fsevents "~2.3.2"

chokidar@^3.4.1:
version "3.4.3"
Expand Down Expand Up @@ -360,6 +368,11 @@ fsevents@~2.1.2:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805"
integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==

fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

get-caller-file@^2.0.1:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
Expand All @@ -379,6 +392,13 @@ glob-parent@~5.1.0:
dependencies:
is-glob "^4.0.1"

glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
dependencies:
is-glob "^4.0.1"

graceful-fs@^4.1.9:
version "4.2.3"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
Expand Down Expand Up @@ -415,6 +435,11 @@ ignore@^5.1.4:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==

immutable@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/immutable/-/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23"
integrity sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw==

import-fresh@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
Expand Down Expand Up @@ -626,7 +651,7 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

picomatch@^2.0.4, picomatch@^2.0.7:
picomatch@^2.0.4:
version "2.2.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"
integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==
Expand Down Expand Up @@ -693,20 +718,20 @@ readable-stream@3:
string_decoder "^1.1.1"
util-deprecate "^1.0.1"

readdirp@~3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.3.0.tgz#984458d13a1e42e2e9f5841b129e162f369aff17"
integrity sha512-zz0pAkSPOXXm1viEwygWIPSPkcBYjW1xU5j/JBh5t9bGCJwa6f9+BJa6VaB2g+b55yVrmXzqkyLf4xaWYM0IkQ==
dependencies:
picomatch "^2.0.7"

readdirp@~3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e"
integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==
dependencies:
picomatch "^2.2.1"

readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
dependencies:
picomatch "^2.2.1"

regenerator-runtime@^0.13.4:
version "0.13.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
Expand All @@ -732,12 +757,14 @@ safe-buffer@~5.2.0:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519"
integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==

sass@^1.26.10:
version "1.30.0"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.30.0.tgz#60bbbbaf76ba10117e61c6c24f00161c3d60610e"
integrity sha512-26EUhOXRLaUY7+mWuRFqGeGGNmhB1vblpTENO1Z7mAzzIZeVxZr9EZoaY1kyGLFWdSOZxRMAufiN2mkbO6dAlw==
sass@1.49.0:
version "1.49.0"
resolved "https://registry.npmjs.org/sass/-/sass-1.49.0.tgz#65ec1b1d9a6bc1bae8d2c9d4b392c13f5d32c078"
integrity sha512-TVwVdNDj6p6b4QymJtNtRS2YtLJ/CqZriGg0eIAbAKMlN8Xy6kbv33FsEZSF7FufFFM705SQviHjjThfaQ4VNw==
dependencies:
chokidar ">=2.0.0 <4.0.0"
chokidar ">=3.0.0 <4.0.0"
immutable "^4.0.0"
source-map-js ">=0.6.2 <2.0.0"

semver-compare@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -776,6 +803,11 @@ slash@^3.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==

"source-map-js@>=0.6.2 <2.0.0":
version "1.0.2"
resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==

source-map@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
Expand Down Expand Up @@ -837,10 +869,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

typescript@4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
typescript@4.5.5:
version "4.5.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

util-deprecate@^1.0.1:
version "1.0.2"
Expand Down

0 comments on commit f317779

Please sign in to comment.