gulpfile.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import * as buildTools from "turbo-gulp";
  2. import { LibTarget, registerLibTasks } from "turbo-gulp/targets/lib";
  3. import { MochaTarget, registerMochaTasks } from "turbo-gulp/targets/mocha";
  4. import gulp from "gulp";
  5. import minimist from "minimist";
  6. interface Options {
  7. devDist?: string;
  8. }
  9. const options: Options & minimist.ParsedArgs = minimist(process.argv.slice(2), {
  10. string: ["devDist"],
  11. default: {devDist: undefined},
  12. alias: {devDist: "dev-dist"},
  13. });
  14. const project: buildTools.Project = {
  15. root: __dirname,
  16. packageJson: "package.json",
  17. buildDir: "build",
  18. distDir: "dist",
  19. srcDir: "src",
  20. typescript: {}
  21. };
  22. const lib: LibTarget = {
  23. project,
  24. name: "lib",
  25. srcDir: "src/lib",
  26. scripts: ["**/*.ts"],
  27. mainModule: "index",
  28. dist: {
  29. packageJsonMap: (old: buildTools.PackageJson): buildTools.PackageJson => {
  30. const version: string = options.devDist !== undefined ? `${old.version}-build.${options.devDist}` : old.version;
  31. return <any> {...old, version, scripts: undefined, private: false};
  32. },
  33. npmPublish: {
  34. tag: options.devDist !== undefined ? "next" : "latest",
  35. },
  36. },
  37. tscOptions: {
  38. declaration: true,
  39. skipLibCheck: true,
  40. },
  41. typedoc: {
  42. dir: "typedoc",
  43. name: "Helpers for V8 coverage files",
  44. deploy: {
  45. repository: "git@github.com:demurgos/v8-coverage.git",
  46. branch: "gh-pages",
  47. },
  48. },
  49. copy: [
  50. {
  51. files: ["**/*.json"],
  52. },
  53. ],
  54. clean: {
  55. dirs: ["build/lib", "dist/lib"],
  56. },
  57. };
  58. const test: MochaTarget = {
  59. project,
  60. name: "test",
  61. srcDir: "src",
  62. scripts: ["test/**/*.ts", "lib/**/*.ts", "e2e/*/*.ts"],
  63. customTypingsDir: "src/custom-typings",
  64. tscOptions: {
  65. allowSyntheticDefaultImports: true,
  66. esModuleInterop: true,
  67. skipLibCheck: true,
  68. },
  69. // generateTestMain: true,
  70. copy: [
  71. {
  72. src: "e2e",
  73. // <project-name>/(project|test-resources)/<any>
  74. files: ["*/project/**/*", "*/test-resources/**/*"],
  75. dest: "e2e",
  76. },
  77. ],
  78. clean: {
  79. dirs: ["build/test"],
  80. },
  81. };
  82. const libTasks: any = registerLibTasks(gulp, lib);
  83. registerMochaTasks(gulp, test);
  84. buildTools.projectTasks.registerAll(gulp, project);
  85. gulp.task("all:tsconfig.json", gulp.parallel("lib:tsconfig.json", "test:tsconfig.json"));
  86. gulp.task("dist", libTasks.dist);
  87. gulp.task("default", libTasks.dist);