MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getExistingPackages

Method getExistingPackages

scripts/bumpVersions.js:132–171  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 }
131
132 async getExistingPackages() {
133 // Find what packages already exist on npm
134 let packages = Object.keys(this.workspacePackages);
135 for (let i = 0; i < packages.length; i += 20) {
136 let promises = [];
137 for (let name of packages.slice(i, i + 20)) {
138 let filePath = this.workspacePackages[name].location + '/package.json';
139 let pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'));
140 if (pkg.private) {
141 continue;
142 }
143
144 console.log('Checking ' + name + ' on npm');
145
146 promises.push(
147 fetch(`https://registry.npmjs.com/${name}`)
148 .then(res => {
149 if (res.ok) {
150 return res.json();
151 }
152 })
153 .then(json => {
154 if (!json) {
155 return;
156 }
157
158 let tags = json['dist-tags'];
159 for (let tag in tags) {
160 if (!tags[tag].includes('nightly')) {
161 this.existingPackages.add(name);
162 break;
163 }
164 }
165 })
166 );
167 }
168
169 await Promise.all(promises);
170 }
171 }
172
173 getChangedPackages() {
174 let packagesIndex = process.argv.findIndex(arg => arg === '--add' || arg === '--only');

Callers 1

runMethod · 0.95

Calls 4

sliceMethod · 0.80
pushMethod · 0.80
addMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected