sdadfadas

Форк
0
/
generate_frontend_ts_tasklist.js 
75 строк · 2.6 Кб
1
/**
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
// Run this from the superset-frontend directory with
21
// `node ../scripts/generate_frontend_ts_tasklist.js `, then copy and paste the output into issue
22
// #10004
23
const { readdirSync } = require("fs");
24
const process = require("process");
25

26
const INITIAL_DIRECTORIES = ["spec", "src", "packages"];
27
const DEFAULT_DIRECTORY = process.cwd();
28

29
const getDirectories = (source) =>
30
  readdirSync(source, { withFileTypes: true })
31
    .filter((dirent) => dirent.isDirectory())
32
    .map((dirent) => dirent.name);
33

34
const getFilesByExtensions = (source, extensions) =>
35
  readdirSync(source, { withFileTypes: true })
36
    .filter((dirent) =>
37
      extensions.some((extension) => dirent.name.endsWith(extension))
38
    )
39
    .map((dirent) => dirent.name);
40

41
let directories = INITIAL_DIRECTORIES;
42

43
while (directories.length) {
44
  const curDirectory = directories.pop();
45
  process.chdir(curDirectory);
46
  // Check for existence of js, jsx, ts, and tsx files. Show a filled box if only ts and tsx,
47
  // show an empty box if any js or jsx, and don't print the line if neither exist in the
48
  // directory.
49
  const hasTypeScriptFiles =
50
    getFilesByExtensions("./", [".ts", ".tsx"]).length > 0;
51
  const hasJavaScriptFiles =
52
    getFilesByExtensions("./", [".js", ".jsx"]).length > 0;
53

54
  if (hasJavaScriptFiles) {
55
    console.log(
56
      `${"  ".repeat(
57
        curDirectory.split("/").length - 1
58
      )}- [ ] \`${curDirectory}\``
59
    );
60
  } else if (hasTypeScriptFiles) {
61
    console.log(
62
      `${"  ".repeat(
63
        curDirectory.split("/").length - 1
64
      )}- [x] \`${curDirectory}\``
65
    );
66
  }
67

68
  directories = directories.concat(
69
    getDirectories("./")
70
      .reverse() // For ABC order when pushed into the Array
71
      .filter((name) => name !== "node_modules") // Don't include node_modules in our packages
72
      .map((directory) => `${curDirectory}/${directory}`)
73
  );
74
  process.chdir(DEFAULT_DIRECTORY);
75
}
76

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.