Skip to content

Commit

Permalink
feat: support ESM config for bob
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 11, 2024
1 parent 0c5582b commit 9b41a62
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@babel/preset-react": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"browserslist": "^4.20.4",
"cosmiconfig": "^7.0.1",
"cosmiconfig": "^9.0.0",
"cross-spawn": "^7.0.3",
"dedent": "^0.7.0",
"del": "^6.1.1",
Expand Down
16 changes: 11 additions & 5 deletions packages/react-native-builder-bob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs-extra';
import kleur from 'kleur';
import dedent from 'dedent';
import yargs from 'yargs';
import { cosmiconfigSync } from 'cosmiconfig';
import { cosmiconfig } from 'cosmiconfig';
import isGitDirty from 'is-git-dirty';
import prompts, { type PromptObject } from './utils/prompts';
import * as logger from './utils/logger';
Expand All @@ -16,8 +16,14 @@ import type { Options } from './types';
const { name, version } = require('../package.json');

const root = process.cwd();
const explorer = cosmiconfigSync(name, {
searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs'],
const explorer = cosmiconfig(name, {
stopDir: root,
searchPlaces: [
'package.json',
'bob.config.mjs',
'bob.config.cjs',
'bob.config.js',
],
});

const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
Expand Down Expand Up @@ -46,7 +52,7 @@ yargs
}

const pkg = JSON.parse(await fs.readFile(pak, 'utf-8'));
const result = explorer.search();
const result = await explorer.search();

if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
const { shouldContinue } = await prompts({
Expand Down Expand Up @@ -413,7 +419,7 @@ yargs
);
})
.command('build', 'build files for publishing', {}, async (argv) => {
const result = explorer.search();
const result = await explorer.search();

if (!result?.config) {
logger.exit(
Expand Down
48 changes: 19 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3876,13 +3876,6 @@ __metadata:
languageName: node
linkType: hard

"@types/parse-json@npm:^4.0.0":
version: 4.0.0
resolution: "@types/parse-json@npm:4.0.0"
checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b
languageName: node
linkType: hard

"@types/prompts@npm:^2.0.14":
version: 2.4.4
resolution: "@types/prompts@npm:2.4.4"
Expand Down Expand Up @@ -5621,19 +5614,6 @@ __metadata:
languageName: node
linkType: hard

"cosmiconfig@npm:^7.0.1":
version: 7.1.0
resolution: "cosmiconfig@npm:7.1.0"
dependencies:
"@types/parse-json": ^4.0.0
import-fresh: ^3.2.1
parse-json: ^5.0.0
path-type: ^4.0.0
yaml: ^1.10.0
checksum: c53bf7befc1591b2651a22414a5e786cd5f2eeaa87f3678a3d49d6069835a9d8d1aef223728e98aa8fec9a95bf831120d245096db12abe019fecb51f5696c96f
languageName: node
linkType: hard

"cosmiconfig@npm:^8.0.0":
version: 8.3.6
resolution: "cosmiconfig@npm:8.3.6"
Expand All @@ -5651,6 +5631,23 @@ __metadata:
languageName: node
linkType: hard

"cosmiconfig@npm:^9.0.0":
version: 9.0.0
resolution: "cosmiconfig@npm:9.0.0"
dependencies:
env-paths: ^2.2.1
import-fresh: ^3.3.0
js-yaml: ^4.1.0
parse-json: ^5.2.0
peerDependencies:
typescript: ">=4.9.5"
peerDependenciesMeta:
typescript:
optional: true
checksum: a30c424b53d442ea0bdd24cb1b3d0d8687c8dda4a17ab6afcdc439f8964438801619cdb66e8e79f63b9caa3e6586b60d8bab9ce203e72df6c5e80179b971fe8f
languageName: node
linkType: hard

"create-jest@npm:^29.7.0":
version: 29.7.0
resolution: "create-jest@npm:29.7.0"
Expand Down Expand Up @@ -6589,7 +6586,7 @@ __metadata:
languageName: node
linkType: hard

"env-paths@npm:^2.2.0":
"env-paths@npm:^2.2.0, env-paths@npm:^2.2.1":
version: 2.2.1
resolution: "env-paths@npm:2.2.1"
checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e
Expand Down Expand Up @@ -12849,7 +12846,7 @@ __metadata:
"@types/yargs": ^17.0.10
browserslist: ^4.20.4
concurrently: ^7.2.2
cosmiconfig: ^7.0.1
cosmiconfig: ^9.0.0
cross-spawn: ^7.0.3
dedent: ^0.7.0
del: ^6.1.1
Expand Down Expand Up @@ -15438,13 +15435,6 @@ __metadata:
languageName: node
linkType: hard

"yaml@npm:^1.10.0":
version: 1.10.2
resolution: "yaml@npm:1.10.2"
checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f
languageName: node
linkType: hard

"yargs-parser@npm:^20.2.2, yargs-parser@npm:^20.2.3":
version: 20.2.9
resolution: "yargs-parser@npm:20.2.9"
Expand Down

0 comments on commit 9b41a62

Please sign in to comment.