-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add remote cache provider setup to the create-app command #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0fcdff7
0da3437
8e8b966
2d5fe7e
6b0f68b
e5b15b2
ca8ce20
83a5dc3
7c197b6
518fca5
d0c3955
b4238c0
3798ac2
7f87800
7b603cd
d405a37
63d2caf
86220db
6c67882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'create-rock': patch | ||
| --- | ||
|
|
||
| feat: add remote cache provider setup |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| import * as path from 'node:path'; | ||
| import { resolveAbsolutePath } from '@rock-js/tools'; | ||
| import { | ||
| resolveAbsolutePath, | ||
| type SupportedRemoteCacheProviders, | ||
| } from '@rock-js/tools'; | ||
|
|
||
| export type TemplateInfo = NpmTemplateInfo | LocalTemplateInfo; | ||
|
|
||
|
|
@@ -93,6 +96,58 @@ export const PLATFORMS: TemplateInfo[] = [ | |
| }, | ||
| ]; | ||
|
|
||
| export function remoteCacheProviderToImportTemplate( | ||
adhorodyski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| provider: SupportedRemoteCacheProviders, | ||
| ) { | ||
| switch (provider) { | ||
| case 'github-actions': | ||
| return `import { providerGitHub } from '@rock-js/provider-github';`; | ||
| case 's3': | ||
| return `import { providerS3 } from '@rock-js/provider-s3';`; | ||
| } | ||
| } | ||
|
|
||
| export function remoteCacheProviderToConfigTemplate( | ||
| provider: SupportedRemoteCacheProviders, | ||
| args: Record<string, string>, | ||
| ) { | ||
| switch (provider) { | ||
| case 'github-actions': | ||
| return template([ | ||
| 'remoteCacheProvider: providerGitHub({', | ||
| ` owner: '${args['owner']}',`, | ||
| ` repository: '${args['repository']}',`, | ||
| '}),', | ||
| ]); | ||
adhorodyski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| case 's3': | ||
| return template([ | ||
| 'remoteCacheProvider: providerS3({', | ||
| ` bucket: '${args['bucket']}',`, | ||
| ` region: '${args['region']}',`, | ||
| [` endpoint: '${args['endpoint']}',`, Boolean(args['endpoint'])], | ||
| '}),', | ||
| ]); | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Cache Config Template ErrorsThe |
||
|
|
||
| export function template(lines: Array<string | [string, boolean]>) { | ||
| return lines | ||
| .filter((line) => { | ||
| // If it's a [content, condition] pair, check the condition | ||
| if (Array.isArray(line)) { | ||
| return Boolean(line[1]); | ||
| } | ||
| // If it's just a string, always include it | ||
| return true; | ||
| }) | ||
| .map((line) => { | ||
| // Extract content from [content, condition] pair or use string directly | ||
| const content = Array.isArray(line) ? line[0] : line; | ||
| return content; | ||
| }) | ||
| .join('\n '); | ||
| } | ||
|
|
||
| export function resolveTemplate( | ||
| templates: TemplateInfo[], | ||
| name: string, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.