1/**
2 * Copyright 2021 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import packageJson from '../package.json';
18
19const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
20
21const invalidDeps = new Map<string, string>();
22
23for (const [depKey, depValue] of Object.entries(allDeps)) {
24  if (/[0-9]/.test(depValue[0])) {
25    continue;
26  }
27
28  invalidDeps.set(depKey, depValue);
29}
30
31if (invalidDeps.size > 0) {
32  console.error('Found non-pinned dependencies in package.json:');
33  console.log([...invalidDeps.keys()].map((k) => `  ${k}`).join('\n'));
34  process.exit(1);
35}
36
37process.exit(0);
38