2023-09-04 19:27:20 +08:00
|
|
|
const $ = require('dekko');
|
|
|
|
const chalk = require('chalk');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const includeUseClient = (filename) =>
|
|
|
|
fs.readFileSync(filename).toString().includes('"use client"');
|
|
|
|
|
2024-08-11 14:14:06 +08:00
|
|
|
$('dist/*')
|
|
|
|
.isFile()
|
|
|
|
.assert("doesn't contain use client", (filename) => !includeUseClient(filename));
|
|
|
|
$('{es,lib}/index.js')
|
|
|
|
.isFile()
|
|
|
|
.assert('contain use client', (filename) => includeUseClient(filename));
|
|
|
|
$('{es,lib}/*/index.js')
|
|
|
|
.isFile()
|
|
|
|
.assert('contain use client', (filename) => includeUseClient(filename));
|
2023-09-04 19:27:20 +08:00
|
|
|
|
2024-08-11 14:14:06 +08:00
|
|
|
// check tsx files
|
|
|
|
$('{es,lib}/typography/*.js')
|
|
|
|
.isFile()
|
|
|
|
.assert('contain use client', (filename) => includeUseClient(filename));
|
2023-09-04 19:27:20 +08:00
|
|
|
|
2024-08-11 14:14:06 +08:00
|
|
|
$('{es,lib}/typography/Base/*.js')
|
|
|
|
.isFile()
|
|
|
|
.filter((filename) => !filename.endsWith('/util.js'))
|
|
|
|
.assert('contain use client', (filename) => includeUseClient(filename));
|
2023-09-04 19:27:20 +08:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.log(chalk.green('✨ use client passed!'));
|