diff --git a/.gitignore b/.gitignore index 6aba2523..16b3ae97 100644 --- a/.gitignore +++ b/.gitignore @@ -68,10 +68,12 @@ cdk.out *.tsbuildinfo *.d.ts -*.js .nx/cache .nx/workspace-data !jest.preset.js + +# Used during the publish stage +.npmignore diff --git a/packages/basic-auth/.gitignore b/packages/basic-auth/.gitignore deleted file mode 100644 index 75ecda95..00000000 --- a/packages/basic-auth/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -!jest.config.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -*.d.ts -*.js \ No newline at end of file diff --git a/packages/basic-auth/.npmignore b/packages/basic-auth/.npmignore deleted file mode 100644 index 1464bb5c..00000000 --- a/packages/basic-auth/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ \ No newline at end of file diff --git a/packages/basic-auth/.npmrc b/packages/basic-auth/.npmrc deleted file mode 100644 index 3b9bddfc..00000000 --- a/packages/basic-auth/.npmrc +++ /dev/null @@ -1 +0,0 @@ -10.1.0 \ No newline at end of file diff --git a/packages/basic-auth/.nvmrc b/packages/basic-auth/.nvmrc deleted file mode 100644 index ef1520fc..00000000 --- a/packages/basic-auth/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.7.0 \ No newline at end of file diff --git a/packages/basic-auth/project.json b/packages/basic-auth/project.json index 4bc57253..83c7aa23 100644 --- a/packages/basic-auth/project.json +++ b/packages/basic-auth/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/basic-auth/index.ts", "outputPath": "dist/basic-auth", - "tsConfig": "packages/basic-auth/tsconfig.app.json" - } + "tsConfig": "packages/basic-auth/tsconfig.app.json", + "assets": ["packages/basic-auth/lib/handlers/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs basic-auth {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs basic-auth" + } } }, "tags": [] diff --git a/packages/cloudfront-security-headers/.gitignore b/packages/cloudfront-security-headers/.gitignore deleted file mode 100644 index f60797b6..00000000 --- a/packages/cloudfront-security-headers/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.js -!jest.config.js -*.d.ts -node_modules - -# CDK asset staging directory -.cdk.staging -cdk.out diff --git a/packages/cloudfront-security-headers/.npmignore b/packages/cloudfront-security-headers/.npmignore deleted file mode 100644 index bfd115ba..00000000 --- a/packages/cloudfront-security-headers/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/cloudfront-security-headers/.npmrc b/packages/cloudfront-security-headers/.npmrc deleted file mode 100644 index 3b9bddfc..00000000 --- a/packages/cloudfront-security-headers/.npmrc +++ /dev/null @@ -1 +0,0 @@ -10.1.0 \ No newline at end of file diff --git a/packages/cloudfront-security-headers/.nvmrc b/packages/cloudfront-security-headers/.nvmrc deleted file mode 100644 index ef1520fc..00000000 --- a/packages/cloudfront-security-headers/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.7.0 \ No newline at end of file diff --git a/packages/cloudfront-security-headers/project.json b/packages/cloudfront-security-headers/project.json index 3dc6d82c..7be271a9 100644 --- a/packages/cloudfront-security-headers/project.json +++ b/packages/cloudfront-security-headers/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/cloudfront-security-headers/index.ts", "outputPath": "dist/cloudfront-security-headers", - "tsConfig": "packages/cloudfront-security-headers/tsconfig.app.json" - } + "tsConfig": "packages/cloudfront-security-headers/tsconfig.app.json", + "assets": ["packages/cloudfront-security-headers/lib/handlers/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs cloudfront-security-headers {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs cloudfront-security-headers" + } } }, "tags": [] diff --git a/packages/esbuild/.npmignore b/packages/esbuild/.npmignore deleted file mode 100644 index 01a5f85d..00000000 --- a/packages/esbuild/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -*.ts -!*.d.ts -!*.js diff --git a/packages/esbuild/project.json b/packages/esbuild/project.json index c01f9adc..2b989b88 100644 --- a/packages/esbuild/project.json +++ b/packages/esbuild/project.json @@ -10,7 +10,8 @@ "main": "packages/esbuild/index.ts", "outputPath": "dist/esbuild", "tsConfig": "packages/esbuild/tsconfig.app.json" - } + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +28,12 @@ "publish": { "command": "node tools/scripts/publish.mjs esbuild {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs esbuild" + } } }, "tags": [] diff --git a/packages/feature-env-handlers/project.json b/packages/feature-env-handlers/project.json index f6cccc67..dcbf23e3 100644 --- a/packages/feature-env-handlers/project.json +++ b/packages/feature-env-handlers/project.json @@ -10,7 +10,8 @@ "main": "packages/feature-env-handlers/index.ts", "outputPath": "dist/feature-env-handlers", "tsConfig": "packages/feature-env-handlers/tsconfig.app.json" - } + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +28,12 @@ "publish": { "command": "node tools/scripts/publish.mjs feature-env-handlers {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs feature-env-handlers" + } } }, "tags": [] diff --git a/packages/geoip-redirect/.gitignore b/packages/geoip-redirect/.gitignore deleted file mode 100644 index 8f77f768..00000000 --- a/packages/geoip-redirect/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -!jest.config.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -*.d.ts -*.js diff --git a/packages/geoip-redirect/.npmignore b/packages/geoip-redirect/.npmignore deleted file mode 100644 index bfd115ba..00000000 --- a/packages/geoip-redirect/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/geoip-redirect/project.json b/packages/geoip-redirect/project.json index ffe1d882..c47c11c8 100644 --- a/packages/geoip-redirect/project.json +++ b/packages/geoip-redirect/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/geoip-redirect/index.ts", "outputPath": "dist/geoip-redirect", - "tsConfig": "packages/geoip-redirect/tsconfig.app.json" - } + "tsConfig": "packages/geoip-redirect/tsconfig.app.json", + "assets": ["packages/geoip-redirect/lib/handlers/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs geoip-redirect {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs geoip-redirect" + } } }, "tags": [] diff --git a/packages/graphql-mesh-server/.npmignore b/packages/graphql-mesh-server/.npmignore deleted file mode 100644 index b41cc365..00000000 --- a/packages/graphql-mesh-server/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!assets/handlers/**/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/graphql-mesh-server/project.json b/packages/graphql-mesh-server/project.json index 6a66a28a..7fa43e11 100644 --- a/packages/graphql-mesh-server/project.json +++ b/packages/graphql-mesh-server/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/graphql-mesh-server/index.ts", "outputPath": "dist/graphql-mesh-server", - "tsConfig": "packages/graphql-mesh-server/tsconfig.app.json" - } + "tsConfig": "packages/graphql-mesh-server/tsconfig.app.json", + "assets": ["packages/graphql-mesh-server/assets/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs graphql-mesh-server {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs graphql-mesh-server" + } } }, "tags": [] diff --git a/packages/prerender-fargate/.gitignore b/packages/prerender-fargate/.gitignore deleted file mode 100644 index 14559189..00000000 --- a/packages/prerender-fargate/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!lib/prerender/** diff --git a/packages/prerender-fargate/.npmignore b/packages/prerender-fargate/.npmignore deleted file mode 100644 index bfd115ba..00000000 --- a/packages/prerender-fargate/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/prerender-fargate/project.json b/packages/prerender-fargate/project.json index 62be1c77..7001d1ad 100644 --- a/packages/prerender-fargate/project.json +++ b/packages/prerender-fargate/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/prerender-fargate/index.ts", "outputPath": "dist/prerender-fargate", - "tsConfig": "packages/prerender-fargate/tsconfig.app.json" - } + "tsConfig": "packages/prerender-fargate/tsconfig.app.json", + "assets": ["packages/prerender-fargate/lib/prerender/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs prerender-fargate {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs prerender-fargate" + } } }, "tags": [] diff --git a/packages/prerender-proxy/.npmignore b/packages/prerender-proxy/.npmignore deleted file mode 100644 index 1464bb5c..00000000 --- a/packages/prerender-proxy/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ \ No newline at end of file diff --git a/packages/prerender-proxy/project.json b/packages/prerender-proxy/project.json index 7086bc2e..c8b23d8c 100644 --- a/packages/prerender-proxy/project.json +++ b/packages/prerender-proxy/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/prerender-proxy/index.ts", "outputPath": "dist/prerender-proxy", - "tsConfig": "packages/prerender-proxy/tsconfig.app.json" - } + "tsConfig": "packages/prerender-proxy/tsconfig.app.json", + "assets": ["packages/prerender-proxy/lib/handlers/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -30,6 +32,12 @@ "publish": { "command": "node tools/scripts/publish.mjs prerender-proxy {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs prerender-proxy" + } } }, "tags": [] diff --git a/packages/rabbitmq/.gitignore b/packages/rabbitmq/.gitignore deleted file mode 100644 index 4bdca62e..00000000 --- a/packages/rabbitmq/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.js -!jest.config.js -*.d.ts -node_modules - -# CDK asset staging directory -.cdk.staging -cdk.out \ No newline at end of file diff --git a/packages/rabbitmq/.npmignore b/packages/rabbitmq/.npmignore deleted file mode 100644 index 1464bb5c..00000000 --- a/packages/rabbitmq/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ \ No newline at end of file diff --git a/packages/rabbitmq/.npmrc b/packages/rabbitmq/.npmrc deleted file mode 100644 index 3b9bddfc..00000000 --- a/packages/rabbitmq/.npmrc +++ /dev/null @@ -1 +0,0 @@ -10.1.0 \ No newline at end of file diff --git a/packages/rabbitmq/.nvmrc b/packages/rabbitmq/.nvmrc deleted file mode 100644 index ef1520fc..00000000 --- a/packages/rabbitmq/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.7.0 \ No newline at end of file diff --git a/packages/rabbitmq/project.json b/packages/rabbitmq/project.json index 24079ab9..3aed5d23 100644 --- a/packages/rabbitmq/project.json +++ b/packages/rabbitmq/project.json @@ -10,7 +10,8 @@ "main": "packages/rabbitmq/index.ts", "outputPath": "dist/rabbitmq", "tsConfig": "packages/rabbitmq/tsconfig.app.json" - } + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +28,12 @@ "publish": { "command": "node tools/scripts/publish.mjs rabbitmq {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs rabbitmq" + } } }, "tags": [] diff --git a/packages/shared-vpc/.gitignore b/packages/shared-vpc/.gitignore deleted file mode 100644 index f60797b6..00000000 --- a/packages/shared-vpc/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.js -!jest.config.js -*.d.ts -node_modules - -# CDK asset staging directory -.cdk.staging -cdk.out diff --git a/packages/shared-vpc/.npmignore b/packages/shared-vpc/.npmignore deleted file mode 100644 index 1464bb5c..00000000 --- a/packages/shared-vpc/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ \ No newline at end of file diff --git a/packages/shared-vpc/project.json b/packages/shared-vpc/project.json index 68677b75..c42bd1fb 100644 --- a/packages/shared-vpc/project.json +++ b/packages/shared-vpc/project.json @@ -10,7 +10,8 @@ "main": "packages/shared-vpc/index.ts", "outputPath": "dist/shared-vpc", "tsConfig": "packages/shared-vpc/tsconfig.app.json" - } + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +28,12 @@ "publish": { "command": "node tools/scripts/publish.mjs shared-vpc {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs shared-vpc" + } } }, "tags": [] diff --git a/packages/static-hosting/.gitignore b/packages/static-hosting/.gitignore deleted file mode 100644 index 8f77f768..00000000 --- a/packages/static-hosting/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -!jest.config.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -*.d.ts -*.js diff --git a/packages/static-hosting/.npmignore b/packages/static-hosting/.npmignore deleted file mode 100644 index bfd115ba..00000000 --- a/packages/static-hosting/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/static-hosting/.npmrc b/packages/static-hosting/.npmrc deleted file mode 100644 index 3b9bddfc..00000000 --- a/packages/static-hosting/.npmrc +++ /dev/null @@ -1 +0,0 @@ -10.1.0 \ No newline at end of file diff --git a/packages/static-hosting/.nvmrc b/packages/static-hosting/.nvmrc deleted file mode 100644 index ef1520fc..00000000 --- a/packages/static-hosting/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.7.0 \ No newline at end of file diff --git a/packages/static-hosting/project.json b/packages/static-hosting/project.json index e2295d52..6bd116aa 100644 --- a/packages/static-hosting/project.json +++ b/packages/static-hosting/project.json @@ -9,8 +9,10 @@ "options": { "main": "packages/static-hosting/index.ts", "outputPath": "dist/static-hosting", - "tsConfig": "packages/static-hosting/tsconfig.app.json" - } + "tsConfig": "packages/static-hosting/tsconfig.app.json", + "assets": ["packages/static-hosting/lib/handlers/**"] + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +29,12 @@ "publish": { "command": "node tools/scripts/publish.mjs static-hosting {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs static-hosting" + } } }, "tags": [] diff --git a/packages/waf/.gitignore b/packages/waf/.gitignore deleted file mode 100644 index 8f77f768..00000000 --- a/packages/waf/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# Node artifact files -node_modules/ -dist/ - -# Compiled Java class files -*.class - -# Compiled Python bytecode -*.py[cod] - -# Log files -*.log - -# Package files -*.jar - -# Maven -target/ -dist/ - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - -# Applications -*.app -*.exe -*.war - -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv - -!jest.config.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -*.d.ts -*.js diff --git a/packages/waf/.npmignore b/packages/waf/.npmignore deleted file mode 100644 index bfd115ba..00000000 --- a/packages/waf/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -*.ts -!lib/handlers/*.ts -!*.d.ts -!*.js - -# CDK asset staging directory -.cdk.staging -cdk.out - -# Samples -sample/ diff --git a/packages/waf/.npmrc b/packages/waf/.npmrc deleted file mode 100644 index 3b9bddfc..00000000 --- a/packages/waf/.npmrc +++ /dev/null @@ -1 +0,0 @@ -10.1.0 \ No newline at end of file diff --git a/packages/waf/.nvmrc b/packages/waf/.nvmrc deleted file mode 100644 index ef1520fc..00000000 --- a/packages/waf/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.7.0 \ No newline at end of file diff --git a/packages/waf/project.json b/packages/waf/project.json index 4ba6c7d3..a51d9a44 100644 --- a/packages/waf/project.json +++ b/packages/waf/project.json @@ -10,7 +10,8 @@ "main": "packages/waf/index.ts", "outputPath": "dist/waf", "tsConfig": "packages/waf/tsconfig.app.json" - } + }, + "dependsOn": ["merge-gitignore"] }, "lint": { "executor": "@nx/eslint:lint", @@ -27,6 +28,12 @@ "publish": { "command": "node tools/scripts/publish.mjs waf {args.ver} {args.tag}", "dependsOn": ["build"] + }, + "merge-gitignore": { + "executor": "nx:run-commands", + "options": { + "command": "node tools/scripts/merge-gitignore.mjs waf" + } } }, "tags": [] diff --git a/tools/scripts/merge-gitignore.mjs b/tools/scripts/merge-gitignore.mjs new file mode 100644 index 00000000..311cbdd8 --- /dev/null +++ b/tools/scripts/merge-gitignore.mjs @@ -0,0 +1,74 @@ +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; + +// Get the current directory using `import.meta.url` +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +function invariant(condition, message) { + if (!condition) { + console.error(message); + process.exit(1); + } +} + +const [, , packageName] = process.argv; +invariant(packageName, `No package name provided.`); + +const rootGitIgnorePath = path.resolve(__dirname, "../../.gitignore"); +const packageDirectory = path.resolve( + __dirname, + `../../packages/${packageName}` +); +const rootNpmIgnorePath = path.resolve(__dirname, "../../.npmignore"); + +// Read and process the root .gitignore +const rootGitIgnore = fs.existsSync(rootGitIgnorePath) + ? fs.readFileSync(rootGitIgnorePath, "utf-8") + : ""; + +// Read and process the package's ignore files +function readIgnoreFile(fileName) { + const filePath = `${packageDirectory}/${fileName}`; + + if (fs.existsSync(filePath)) { + // Get the relative path to the root + const fileRelativeDirectory = path.relative( + path.resolve(__dirname, "../.."), + packageDirectory + ); + + return fs + .readFileSync(filePath, "utf-8") + .split("\n") + .map(line => { + // Adjust relative paths, skip comments and empty lines + if (!line.trim() || line.startsWith("#")) return line; + if (line.startsWith("!")) { + return `!${path.join(fileRelativeDirectory, line.slice(1))}`; + } + return path.join(fileRelativeDirectory, line); + }) + .join("\n"); + } else { + return ""; + } +} + +// Combine and de-duplicate lines +const combinedGitIgnore = Array.from( + new Set([ + ...rootGitIgnore.split("\n"), + "# Ignores added from .gitignore at the package level", + ...readIgnoreFile(".gitignore").split("\n"), + "# Ignores added from .npmignore at the package level", + ...readIgnoreFile(".npmignore").split("\n"), + ]) +) + .filter(Boolean) + .join("\n"); + +// Write the merged .npmignore +fs.writeFileSync(rootNpmIgnorePath, combinedGitIgnore); +console.log(`Merged .gitignore written to ${rootGitIgnorePath}`);