-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add warning when watching Admin/Website without API deployed (#4350
- Loading branch information
Showing
15 changed files
with
96 additions
and
88 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
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 was deleted.
Oops, something went wrong.
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 @@ | ||
const sleep = (ms = 1500) => new Promise(resolve => setTimeout(resolve, ms)); | ||
|
||
module.exports = sleep; |
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,8 @@ | ||
const sleepSync = (ms = 1500) => { | ||
const start = Date.now(); | ||
while (Date.now() < start + ms) { | ||
// Do nothing. | ||
} | ||
}; | ||
|
||
module.exports = sleepSync; |
50 changes: 19 additions & 31 deletions
50
packages/serverless-cms-aws/src/admin/plugins/ensureApiDeployed.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 |
---|---|---|
@@ -1,37 +1,25 @@ | ||
import { getStackOutput } from "@webiny/cli-plugin-deploy-pulumi/utils"; | ||
import { | ||
createBeforeBuildPlugin, | ||
createBeforeWatchPlugin | ||
} from "@webiny/cli-plugin-deploy-pulumi/plugins"; | ||
import { createBeforeBuildPlugin } from "@webiny/cli-plugin-deploy-pulumi/plugins"; | ||
import { GracefulError } from "@webiny/cli-plugin-deploy-pulumi/utils"; | ||
import type { Callable } from "@webiny/cli-plugin-deploy-pulumi/plugins/PulumiCommandLifecycleEventHookPlugin"; | ||
|
||
const createPluginCallable: (command: "build" | "watch") => Callable = | ||
command => | ||
({ env }, ctx) => { | ||
const output = getStackOutput({ folder: "apps/api", env }); | ||
const apiDeployed = output && Object.keys(output).length > 0; | ||
if (apiDeployed) { | ||
return; | ||
} | ||
export const ensureApiDeployedBeforeBuild = createBeforeBuildPlugin(({ env }, ctx) => { | ||
const output = getStackOutput({ folder: "apps/api", env }); | ||
const apiDeployed = output && Object.keys(output).length > 0; | ||
if (apiDeployed) { | ||
return; | ||
} | ||
|
||
const apiAppName = ctx.error.hl("API"); | ||
const adminAppName = ctx.error.hl("Admin"); | ||
const cmd = ctx.error.hl(`yarn webiny deploy api --env ${env}`); | ||
ctx.error( | ||
`Cannot ${command} ${adminAppName} project application before deploying ${apiAppName}.` | ||
); | ||
const apiAppName = ctx.error.hl("API"); | ||
const adminAppName = ctx.error.hl("Admin"); | ||
const cmd = ctx.error.hl(`yarn webiny deploy api --env ${env}`); | ||
ctx.error(`Cannot build ${adminAppName} project application before deploying ${apiAppName}.`); | ||
|
||
throw new GracefulError( | ||
[ | ||
`Before ${command}ing ${adminAppName} project application, please`, | ||
`deploy ${apiAppName} first by running: ${cmd}.` | ||
].join(" ") | ||
); | ||
}; | ||
throw new GracefulError( | ||
[ | ||
`Before building ${adminAppName} project application, please`, | ||
`deploy ${apiAppName} first by running: ${cmd}.` | ||
].join(" ") | ||
); | ||
}); | ||
|
||
export const ensureApiDeployedBeforeBuild = createBeforeBuildPlugin(createPluginCallable("build")); | ||
ensureApiDeployedBeforeBuild.name = "admin.before-deploy.ensure-api-deployed"; | ||
|
||
export const ensureApiDeployedBeforeWatch = createBeforeWatchPlugin(createPluginCallable("watch")); | ||
ensureApiDeployedBeforeWatch.name = "admin.before-watch.ensure-api-deployed"; | ||
ensureApiDeployedBeforeBuild.name = "admin.before-build.ensure-api-deployed"; |
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
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
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
50 changes: 19 additions & 31 deletions
50
packages/serverless-cms-aws/src/website/plugins/ensureApiDeployed.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 |
---|---|---|
@@ -1,37 +1,25 @@ | ||
import { getStackOutput } from "@webiny/cli-plugin-deploy-pulumi/utils"; | ||
import { | ||
createBeforeBuildPlugin, | ||
createBeforeWatchPlugin | ||
} from "@webiny/cli-plugin-deploy-pulumi/plugins"; | ||
import { createBeforeBuildPlugin } from "@webiny/cli-plugin-deploy-pulumi/plugins"; | ||
import { GracefulError } from "@webiny/cli-plugin-deploy-pulumi/utils"; | ||
import type { Callable } from "@webiny/cli-plugin-deploy-pulumi/plugins/PulumiCommandLifecycleEventHookPlugin"; | ||
|
||
const createPluginCallable: (command: "build" | "watch") => Callable = | ||
command => | ||
({ env }, ctx) => { | ||
const output = getStackOutput({ folder: "apps/api", env }); | ||
const apiDeployed = output && Object.keys(output).length > 0; | ||
if (apiDeployed) { | ||
return; | ||
} | ||
export const ensureApiDeployedBeforeBuild = createBeforeBuildPlugin(({ env }, ctx) => { | ||
const output = getStackOutput({ folder: "apps/api", env }); | ||
const apiDeployed = output && Object.keys(output).length > 0; | ||
if (apiDeployed) { | ||
return; | ||
} | ||
|
||
const apiAppName = ctx.error.hl("API"); | ||
const websiteAppName = ctx.error.hl("Website"); | ||
const cmd = ctx.error.hl(`yarn webiny deploy api --env ${env}`); | ||
ctx.error( | ||
`Cannot ${command} ${websiteAppName} project application before deploying ${apiAppName}.` | ||
); | ||
const apiAppName = ctx.error.hl("API"); | ||
const websiteAppName = ctx.error.hl("Website"); | ||
const cmd = ctx.error.hl(`yarn webiny deploy api --env ${env}`); | ||
ctx.error(`Cannot build ${websiteAppName} project application before deploying ${apiAppName}.`); | ||
|
||
throw new GracefulError( | ||
[ | ||
`Before ${command}ing ${websiteAppName} project application, please`, | ||
`deploy ${apiAppName} first by running: ${cmd}.` | ||
].join(" ") | ||
); | ||
}; | ||
throw new GracefulError( | ||
[ | ||
`Before building ${websiteAppName} project application, please`, | ||
`deploy ${apiAppName} first by running: ${cmd}.` | ||
].join(" ") | ||
); | ||
}); | ||
|
||
export const ensureApiDeployedBeforeBuild = createBeforeBuildPlugin(createPluginCallable("build")); | ||
ensureApiDeployedBeforeBuild.name = "website.before-deploy.ensure-api-deployed"; | ||
|
||
export const ensureApiDeployedBeforeWatch = createBeforeWatchPlugin(createPluginCallable("watch")); | ||
ensureApiDeployedBeforeWatch.name = "website.before-watch.ensure-api-deployed"; | ||
ensureApiDeployedBeforeBuild.name = "website.before-build.ensure-api-deployed"; |