MCPcopy Index your code
hub / github.com/adobe/react-spectrum / addDeps

Function addDeps

scripts/buildPublishedAPI.js:128–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 let packagesDir = path.join(__dirname, '..', 'packages');
127 let packages = glob.sync('*/**/package.json', {cwd: packagesDir, ignore: ['**/node_modules/**']});
128 async function addDeps() {
129 let promises = [];
130 for (let p of packages) {
131 let promise = new Promise((resolve, reject) => {
132 readFile(path.join(packagesDir, p), 'utf8').then(async contents => {
133 let json = JSON.parse(contents);
134 if (!json.private && json.name !== '@adobe/react-spectrum') {
135 try {
136 // this npm view will fail if the package isn't on npm
137 // otherwise we want to check if there is any version that isn't a nightly
138 let results = JSON.parse(await run('npm', ['view', json.name, 'versions', '--json']));
139 if (results.some(version => !version.includes('nightly'))) {
140 pkg.dependencies[json.name] = 'latest';
141 console.log('added', json.name);
142 }
143 } catch (e) {
144 // continue
145 }
146 }
147 resolve();
148 });
149 });
150 promises.push(promise);
151 }
152 return Promise.all(promises);
153 }
154
155 await addDeps();
156 pkg.devDependencies['babel-plugin-transform-glob-import'] = '*';

Callers 1

buildFunction · 0.85

Calls 4

pushMethod · 0.80
runFunction · 0.70
resolveFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected