@samitouri / QOS-React-2 / commits / fd91191c94

Script to add/fix copyright

Adds a script to automate adding/updating the copyright header to all appropriate files. For now i've excluded fixture inputs, just because it would impact fixture outputs too, but we can add them in a later PR if we want.

Joe Savona committed Apr 5, 2023 at 12:21 UTC fd91191c9478ebb1ec3227a8d028515a40215338
3 files changed +65 -2
compiler/forget/scripts/copyright.js new
+63
@@ -0,0 +1,63 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +"use strict";
8 +
9 +const fs = require("fs");
10 +const glob = require("glob");
11 +
12 +const META_COPYRIGHT_COMMENT_BLOCK = `/**
13 + * Copyright (c) Meta Platforms, Inc. and affiliates.
14 + *
15 + * This source code is licensed under the MIT license found in the
16 + * LICENSE file in the root directory of this source tree.
17 + */`;
18 +
19 +const files = glob.sync("**/*.{js,ts,tsx,jsx}", {
20 + ignore: [
21 + "**/dist/**",
22 + "**/node_modules/**",
23 + "test262/**",
24 + "**/__tests__/fixtures/**/*.js",
25 + ],
26 +});
27 +
28 +const updatedFiles = new Map();
29 +let hasErrors = false;
30 +files.forEach((file) => {
31 + try {
32 + const result = processFile(file);
33 + if (result != null) {
34 + updatedFiles.set(file, result);
35 + }
36 + } catch (e) {
37 + console.error(e);
38 + hasErrors = true;
39 + }
40 +});
41 +if (hasErrors) {
42 + console.error("Update failed");
43 + process.exit(1);
44 +} else {
45 + for (const [file, source] of updatedFiles) {
46 + fs.writeFileSync(file, source, "utf8");
47 + }
48 + console.log("Update complete");
49 +}
50 +
51 +function processFile(file) {
52 + let source = fs.readFileSync(file, "utf8");
53 +
54 + if (source.indexOf(META_COPYRIGHT_COMMENT_BLOCK) === 0) {
55 + return null;
56 + }
57 + if (/^\/\*\*/.test(source)) {
58 + source = source.replace(/\/\*\*[^\/]+\//, META_COPYRIGHT_COMMENT_BLOCK);
59 + } else {
60 + source = `${META_COPYRIGHT_COMMENT_BLOCK}\n\n${source}`;
61 + }
62 + return source;
63 +}
compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts
+1 -1
@@ -1,5 +1,5 @@
1 /**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
compiler/forget/src/Utils/todo.ts
+1 -1
@@ -1,5 +1,5 @@
1 /**
2 - * Copyright (c) Facebook, Inc. and its affiliates.
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.