Skip to content

Commit

Permalink
Merge pull request #42 from mj-studio-library/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
mym0404 authored Mar 20, 2024
2 parents 0cfd251 + 2ecff8f commit b30203c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
31 changes: 26 additions & 5 deletions bin/theme-gen.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
#!/usr/bin/env node
/* eslint-disable max-len */
// region ZX Util
const fs = require('fs-extra');
const fs = require('fs');
const path = require('path');
const { moveSync } = require('fs-extra');

const filename = path.basename(__filename);
const _printTag = 'Theme Gen' || filename;

const { exec } = require('child_process');

function execa(command, ...args) {
return new Promise((resolve, reject) => {
const fullCommand = `${command} ${args.join(' ')}`;
exec(fullCommand, (error, stdout, stderr) => {
if (error) {
reject(error);
} else {
resolve(stdout.trim());
}
});
});
}

function exist(path) {
return fs.existsSync(path);
}
Expand Down Expand Up @@ -60,7 +74,6 @@ function printError(...args) {
// endregion

const go = async () => {
const { $ } = await import('execa');
const source = process.argv[2];
if (!source) {
printError('Source path is not passed');
Expand All @@ -75,7 +88,15 @@ const go = async () => {
'./node_modules/react-native-themed-styled-system/lib/typescript/@types/ThemedTypings.d.ts';

try {
await $`npx -y react-native-themed-styled-system-cli generate --out ${tmpFile} ${source}`;
await execa(
'npx',
'-y',
'react-native-themed-styled-system-cli',
'generate',
'--out',
tmpFile,
source,
);

/**
* export interface ThemedTypings {
Expand Down Expand Up @@ -113,7 +134,7 @@ const go = async () => {
result = result.replace(/\|[\s ]*\n/g, ';');

write(tmpFile, result);
moveSync(tmpFile, outputFile, { overwrite: true });
fs.renameSync(tmpFile, outputFile);
// await fixLint(outputFile);
printSuccess(`🎉 Theme Typing Generated in '${outputFile}'`);
} catch (e) {
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
"@commitlint/config-conventional": "^19.1.0",
"@mj-studio/eslint-config-react": "^1.0.4",
"@testing-library/react-hooks": "^8.0.1",
"@types/fs-extra": "^11",
"@types/invariant": "^2.2.37",
"@types/jest": "^29.5.12",
"@types/react": "^18.2.65",
"@types/react-test-renderer": "^18",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.2.0",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"metro-react-native-babel-preset": "^0.77.0",
Expand Down
24 changes: 1 addition & 23 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3456,16 +3456,6 @@ __metadata:
languageName: node
linkType: hard

"@types/fs-extra@npm:^11":
version: 11.0.4
resolution: "@types/fs-extra@npm:11.0.4"
dependencies:
"@types/jsonfile": "npm:*"
"@types/node": "npm:*"
checksum: 10c0/9e34f9b24ea464f3c0b18c3f8a82aefc36dc524cc720fc2b886e5465abc66486ff4e439ea3fb2c0acebf91f6d3f74e514f9983b1f02d4243706bdbb7511796ad
languageName: node
linkType: hard

"@types/graceful-fs@npm:^4.1.3":
version: 4.1.9
resolution: "@types/graceful-fs@npm:4.1.9"
Expand Down Expand Up @@ -3531,15 +3521,6 @@ __metadata:
languageName: node
linkType: hard

"@types/jsonfile@npm:*":
version: 6.1.4
resolution: "@types/jsonfile@npm:6.1.4"
dependencies:
"@types/node": "npm:*"
checksum: 10c0/b12d068b021e4078f6ac4441353965769be87acf15326173e2aea9f3bf8ead41bd0ad29421df5bbeb0123ec3fc02eb0a734481d52903704a1454a1845896b9eb
languageName: node
linkType: hard

"@types/node@npm:*":
version: 20.11.19
resolution: "@types/node@npm:20.11.19"
Expand Down Expand Up @@ -6607,7 +6588,7 @@ __metadata:
languageName: node
linkType: hard

"fs-extra@npm:^11.0.0, fs-extra@npm:^11.2.0":
"fs-extra@npm:^11.0.0":
version: 11.2.0
resolution: "fs-extra@npm:11.2.0"
dependencies:
Expand Down Expand Up @@ -11160,15 +11141,12 @@ __metadata:
"@mj-studio/eslint-config-react": "npm:^1.0.4"
"@mj-studio/js-util": "npm:^1.0.29"
"@testing-library/react-hooks": "npm:^8.0.1"
"@types/fs-extra": "npm:^11"
"@types/invariant": "npm:^2.2.37"
"@types/jest": "npm:^29.5.12"
"@types/react": "npm:^18.2.65"
"@types/react-test-renderer": "npm:^18"
cz-conventional-changelog: "npm:^3.3.0"
eslint: "npm:^8.2.0"
execa: "npm:^8.0.1"
fs-extra: "npm:^11.2.0"
husky: "npm:^9.0.11"
invariant: "npm:^2.2.4"
jest: "npm:^29.7.0"
Expand Down

0 comments on commit b30203c

Please sign in to comment.