-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12a04e5
commit 8f47241
Showing
20 changed files
with
288 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# nx-netlify-deploy | ||
|
||
An executor and generator for netlify deploys using the cli | ||
|
||
## Add `deploy` target to an existing project | ||
|
||
`npx nx g @k11r/nx-netlify-deploy:add-deploy-target <app-name> --site-id=<site-id>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"executors": { | ||
"deploy": { | ||
"implementation": "./src/executors/deploy/executor", | ||
"schema": "./src/executors/deploy/schema.json", | ||
"description": "Netlify deploy executor" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"name": "nx-netlify-deploy", | ||
"version": "0.0.1", | ||
"generators": { | ||
"add-deploy-target": { | ||
"factory": "./src/generators/add-deploy-target/generator", | ||
"schema": "./src/generators/add-deploy-target/schema.json", | ||
"description": "Adds the netlify deploy target" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
displayName: 'nx-netlify-deploy', | ||
preset: '../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../coverage/packages/nx-netlify-deploy', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@k11r/nx-netlify-deploy", | ||
"version": "0.0.3", | ||
"generators": "./generators.json", | ||
"executors": "./executors.json", | ||
"peerDependencies": { | ||
"netlify-cli": ">8" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/nx-netlify-deploy/src/executors/deploy/executor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {ExecutorContext} from "@nrwl/tao/src/shared/workspace"; | ||
import {DeployExecutorSchema} from "./schema"; | ||
import {execSync} from "child_process"; | ||
|
||
export default async function deployExecutor(options: DeployExecutorSchema, context: ExecutorContext) { | ||
const {siteId, skipBuild, prod, outputPath} = options; | ||
|
||
if (!skipBuild) { | ||
console.log('Building app currently not supported'); | ||
} | ||
|
||
const command = `npx netlify deploy --dir=${outputPath} --site=${siteId} ${prod ? '--prod' : ''}`; | ||
|
||
try { | ||
execSync(command); | ||
} catch (e) { | ||
return {success: false, error: e.toString()} | ||
} | ||
|
||
return { success: true }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface DeployExecutorSchema { | ||
siteId: string; | ||
outputPath: string; | ||
skipBuild?: boolean | ||
prod?: boolean | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/nx-netlify-deploy/src/executors/deploy/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"title": "Deploy executor", | ||
"description": "Deploys an app to Netlify", | ||
"type": "object", | ||
"properties": { | ||
"siteId": { | ||
"type": "string", | ||
"description": "Netlify site id" | ||
}, | ||
"outputPath": { | ||
"type": "string", | ||
"description": "Path to artifacts" | ||
}, | ||
"skipBuild": { | ||
"type": "boolean", | ||
"description": "Should build step gets skipped", | ||
"default": false | ||
}, | ||
"prod": { | ||
"type": "boolean", | ||
"description": "Is production deploy", | ||
"default": false | ||
} | ||
}, | ||
"required": ["siteId", "outputPath"] | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/nx-netlify-deploy/src/generators/add-deploy-target/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { readProjectConfiguration, Tree, updateProjectConfiguration } from '@nrwl/devkit'; | ||
import { AddDeployTargetGeneratorSchema } from './schema'; | ||
|
||
export default async function (tree: Tree, options: AddDeployTargetGeneratorSchema) { | ||
try { | ||
console.log("Adding 'deploy' target to " + options.appName); | ||
const projectConfiguration = readProjectConfiguration(tree, options.appName); | ||
const outputPath = options.outputPath ?? projectConfiguration.targets['build']['options']['outputPath']; | ||
|
||
projectConfiguration.targets = { | ||
...projectConfiguration.targets, | ||
deploy: { | ||
executor: '@k11r/nx-netlify-deploy:deploy', | ||
options: { | ||
siteId: options.siteId, | ||
outputPath | ||
}, | ||
}, | ||
}; | ||
updateProjectConfiguration(tree, options.appName, projectConfiguration); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/nx-netlify-deploy/src/generators/add-deploy-target/schema.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface AddDeployTargetGeneratorSchema { | ||
appName: string; | ||
siteId: string; | ||
outputPath?: string; | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/nx-netlify-deploy/src/generators/add-deploy-target/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "AddDeployTarget", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"appName": { | ||
"type": "string", | ||
"description": "Name of the app to add the deploy target to", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
} | ||
}, | ||
"siteId": { | ||
"type": "string", | ||
"description": "Netlify site id" | ||
}, | ||
"outputPath": { | ||
"type": "string", | ||
"description": "Path to the artifacts" | ||
} | ||
}, | ||
"required": [ | ||
"appName", | ||
"siteId" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './executors/deploy/executor'; | ||
export * from './executors/deploy/schema'; | ||
|
||
export * from './generators/add-deploy-target/generator'; | ||
export * from './generators/add-deploy-target/schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["**/*.spec.ts", "**/*.test.ts"], | ||
"include": ["**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"**/*.test.ts", | ||
"**/*.spec.ts", | ||
"**/*.test.tsx", | ||
"**/*.spec.tsx", | ||
"**/*.test.js", | ||
"**/*.spec.js", | ||
"**/*.test.jsx", | ||
"**/*.spec.jsx", | ||
"**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters