Skip to content

Commit

Permalink
Merge branch 'master' of github.com:seek-oss/sku into pnpm-9
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed May 8, 2024
2 parents b9f15b4 + 346d53f commit 6e625a9
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-rockets-invent.md
@@ -0,0 +1,5 @@
---
'sku': patch
---

Remove `rimraf` dependency in favour of Node.js's `rm`
4 changes: 4 additions & 0 deletions .npmrc
Expand Up @@ -6,3 +6,7 @@ public-hoist-pattern[]="*prettier*"
# This bypasses the .pnpm folder that resolveModules looks for
# See https://github.com/seek-oss/sku/blob/275752bd3066e52885d461ef5bcd953aaac3bfff/config/webpack/resolveModules.js
public-hoist-pattern[]="@babel/*"

# `docsify-cli` depends on `docsify` which depends on `opencollective-postinstall` and calls it during `postinstall`.
# For some reason, this call fails on CI, so we need to hoist it.
public-hoist-pattern[]="opencollective-postinstall"
6 changes: 6 additions & 0 deletions fixtures/sku-init/sku-init.test.js
Expand Up @@ -26,6 +26,12 @@ describe('sku init', () => {
it(
'should create a sku.config.ts',
async () => {
const projectName = 'new-project';
await fs.rm(path.join(fixtureDirectory, projectName), {
recursive: true,
force: true,
});

const { child } = await runSkuScriptInDir('init', fixtureDirectory, [
projectName,
]);
Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Expand Up @@ -3,7 +3,11 @@ module.exports = {
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
maxWorkers: process.env.CI ? 2 : undefined,
...(process.env.CI
? {
maxWorkers: 2,
}
: {}),
preset: 'jest-puppeteer',
setupFilesAfterEnv: ['<rootDir>/test-utils/jestSetup.ts'],
snapshotSerializers: [
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -65,7 +65,6 @@
"prettier": "^2.8.8",
"puppeteer": "^21.6.0",
"renovate-config-seek": "^0.4.0",
"rimraf": "^5.0.0",
"typescript": "*"
},
"volta": {
Expand Down
21 changes: 15 additions & 6 deletions packages/sku/lib/buildFileUtils.js
@@ -1,13 +1,15 @@
// @ts-check
const path = require('node:path');
const fs = require('node:fs/promises');
const { rimraf } = require('rimraf');
const { fdir: Fdir } = require('fdir');

const { paths } = require('../context');
const exists = require('./exists');
const copyDirContents = require('./copyDirContents');

const cleanTargetDirectory = () => rimraf(`${paths.target}/*`, { glob: true });
const cleanTargetDirectory = async () => {
fs.rm(paths.target, { recursive: true, force: true });
};

const copyPublicFiles = async () => {
if (await exists(paths.public)) {
Expand All @@ -19,14 +21,21 @@ const ensureTargetDirectory = async () => {
await fs.mkdir(paths.target, { recursive: true });
};

const cleanRenderJs = async () => {
const renderFileGlob = path.join(paths.target, '*render.js');
await rimraf(renderFileGlob, { glob: true });
const cleanStaticRenderEntry = async () => {
const files = await new Fdir()
.withBasePath()
.filter((file) => file.endsWith('render.js'))
.crawl(paths.target)
.withPromise();

for (const file of files) {
await fs.rm(file);
}
};

module.exports = {
cleanTargetDirectory,
copyPublicFiles,
ensureTargetDirectory,
cleanRenderJs,
cleanStaticRenderEntry,
};
1 change: 0 additions & 1 deletion packages/sku/package.json
Expand Up @@ -110,7 +110,6 @@
"prettier": "^2.8.8",
"pretty-ms": "^7.0.1",
"react-refresh": "^0.14.0",
"rimraf": "^5.0.0",
"selfsigned": "^2.1.1",
"semver": "^7.3.4",
"serialize-javascript": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/scripts/build-storybook.js
@@ -1,7 +1,7 @@
// First, ensure the build is running in production mode
process.env.NODE_ENV = 'production';

const { rimraf } = require('rimraf');
const { rm } = require('node:fs/promises');
const { argv, config } = require('../config/args');
const gracefulSpawn = require('../lib/gracefulSpawn');
const { storybookTarget } = require('../context');
Expand All @@ -11,7 +11,7 @@ const { setUpStorybookConfigDirectory } = require('../lib/storybook');

(async () => {
await runVocabCompile();
await rimraf(storybookTarget);
await rm(storybookTarget, { recursive: true, force: true });
await setUpStorybookConfigDirectory();

argv.push('build');
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/scripts/build.js
Expand Up @@ -10,7 +10,7 @@ const {
copyPublicFiles,
cleanTargetDirectory,
ensureTargetDirectory,
cleanRenderJs,
cleanStaticRenderEntry,
} = require('../lib/buildFileUtils');
const { run } = require('../lib/runWebpack');
const createHtmlRenderPlugin = require('../config/webpack/plugins/createHtmlRenderPlugin');
Expand All @@ -31,7 +31,7 @@ const { runVocabCompile } = require('../lib/runVocab');
}),
),
);
await cleanRenderJs();
await cleanStaticRenderEntry();
await copyPublicFiles();

const timeTaken = performance.now();
Expand Down
32 changes: 23 additions & 9 deletions pnpm-lock.yaml

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

10 changes: 4 additions & 6 deletions tests/configure.test.ts
@@ -1,5 +1,4 @@
import { readFile, copyFile, mkdir as makeDir } from 'node:fs/promises';
import { rimraf } from 'rimraf';
import { readFile, copyFile, mkdir as makeDir, rm } from 'node:fs/promises';
import path from 'node:path';
import * as jsonc from 'jsonc-parser';
import { runSkuScriptInDir } from '@sku-private/test-utils';
Expand Down Expand Up @@ -33,10 +32,9 @@ const copyToApp = async (filename: string, folder: string) =>
copyFile(path.join(fixtureFolder, filename), path.join(folder, filename));

const removeAppDir = async (folder: string) =>
rimraf(folder, {
glob: {
dot: true,
},
rm(folder, {
recursive: true,
force: true,
});

const skuPackagePath = path.dirname(require.resolve('sku/package.json'));
Expand Down
1 change: 0 additions & 1 deletion tests/package.json
Expand Up @@ -35,7 +35,6 @@
"dedent": "^1.5.1",
"jsonc-parser": "^3.0.0",
"node-fetch": "^2.6.9",
"rimraf": "^5.0.0",
"strip-ansi": "^6.0.1",
"webpack": "^5.52.0",
"webpack-cli": "^5.0.0",
Expand Down
6 changes: 3 additions & 3 deletions tests/typescript-css-modules.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import path from 'node:path';
import { rimraf } from 'rimraf';
import { rm } from 'node:fs/promises';
import {
dirContentsToObject,
waitForUrls,
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('typescript-css-modules', () => {
afterAll(async () => {
await process.kill();
// Clean up dist dir to prevent pollution of linted files in lint test
await rimraf(distDir);
await rm(distDir, { recursive: true, force: true });
});

it('should create valid app', async () => {
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('typescript-css-modules', () => {
await server.kill();
closeAssetServer();
// Clean up dist-ssr dir to prevent pollution of linted files in lint test
await rimraf(distSsrDir);
await rm(distSsrDir, { recursive: true, force: true });
});

it('should create valid app', async () => {
Expand Down

0 comments on commit 6e625a9

Please sign in to comment.