Skip to content
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

feat: upgrade dependencies #693

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ updates:
interval: weekly
day: friday
time: "04:00"
groups:
development-dependencies:
dependency-type: development

- package-ecosystem: github-actions
open-pull-requests-limit: 20
directory: "/"
schedule:
interval: weekly
day: friday
time: "04:00"
groups:
github-actions-dependencies:
patterns:
- "*"
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
"homepage": "https://reactionable.github.io/reactionable-cli",
"dependencies": {
"@iarna/toml": "^2.2.5",
"chalk": "^4.1.2",
"clipanion": "^3.2.1",
"clipanion": "^4.0.0-rc.2",
"colorette": "^2.0.20",
"deepmerge": "^4.3.1",
"diff": "^5.1.0",
"eta": "^3.1.1",
"figlet": "^1.6.0",
"figlet": "^1.7.0",
"handlebars": "^4.7.8",
"inversify": "^6.0.1",
"inversify": "^6.0.2",
"js-ini": "^1.6.0",
"parse-github-url": "^1.0.2",
"pluralize": "^8.0.0",
Expand All @@ -52,21 +52,21 @@
"typescript": "^5.1.6"
},
"devDependencies": {
"@ts-dev-tools/core": "^1.6.0",
"@types/diff": "^5.0.3",
"@types/figlet": "^1.5.6",
"@types/mock-fs": "^4.13.1",
"@types/parse-github-url": "^1.0.0",
"@types/prompts": "^2.4.4",
"@types/shelljs": "^0.8.12",
"@types/tmp": "^0.2.3",
"fs-extra": "^11.1.1",
"@ts-dev-tools/core": "^1.6.1",
"@types/diff": "^5.0.9",
"@types/figlet": "^1.5.8",
"@types/mock-fs": "^4.13.4",
"@types/parse-github-url": "^1.0.3",
"@types/prompts": "^2.4.9",
"@types/shelljs": "^0.8.15",
"@types/tmp": "^0.2.6",
"fs-extra": "^11.2.0",
"jest-serializer-html": "^7.1.0",
"mock-fs": "^5.2.0",
"mock-spawn": "^0.2.6",
"rimraf": "^5.0.1",
"tmp": "^0.2.1",
"typedoc": "^0.25.0"
"typedoc": "^0.25.6"
},
"eslintConfig": {
"root": true,
Expand Down Expand Up @@ -135,4 +135,4 @@
"tsDevTools": {
"version": "20220617100200-prettier-cache"
}
}
}
125 changes: 67 additions & 58 deletions src/actions/add-hosting/adapters/amplify/Amplify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
this.consoleService.info("Prepare Amplify configuration...");
const projectBranch = await this.gitService.getGitCurrentBranch(realpath, "master");

let projectName = this.getProjectName(realpath);
let projectName = await this.getProjectName(realpath);
if (!projectName) {
const response = await prompts([
{
Expand Down Expand Up @@ -131,27 +131,26 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
await this.addHosting(realpath);

const appFilePath = await this.getAppFilePath(realpath);
await this.fileFactory
.fromFile<TypescriptFile>(appFilePath)
.setImports(
[
{
packageName: "@reactionable/amplify",
modules: { IIdentityContextProviderProps: "" },
},
],
[
{
packageName: "@reactionable/core",
modules: { IIdentityContextProviderProps: "" },
},
]
)
.saveFile();
const appFile = await this.fileFactory.fromFile<TypescriptFile>(appFilePath);
appFile.setImports(
[
{
packageName: "@reactionable/amplify",
modules: { IIdentityContextProviderProps: "" },
},
],
[
{
packageName: "@reactionable/core",
modules: { IIdentityContextProviderProps: "" },
},
]
);
await appFile.saveFile();

const indexFilePath = await this.getEntrypointFilePath(realpath);
await this.fileFactory
.fromFile<TypescriptFile>(indexFilePath)
const entrypointFilePath = await this.getEntrypointFilePath(realpath);
const entrypointFile = await this.fileFactory.fromFile<TypescriptFile>(entrypointFilePath);
entrypointFile
.setImports([
{ packageName: "aws-amplify", modules: { Amplify: TypescriptImport.defaultImport } },
{ packageName: "./aws-exports", modules: { awsconfig: TypescriptImport.defaultImport } },
Expand All @@ -160,32 +159,33 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
modules: { [TypescriptImport.defaultImport]: TypescriptImport.defaultImport },
},
])
.appendContent("Amplify.configure(awsconfig);", "import './index.scss';")
.saveFile();
.appendContent("Amplify.configure(awsconfig);", "import './index.scss';");

await entrypointFile.saveFile();

const i18nFilepath = resolve(
realpath,
await this.getLibDirectoryPath(realpath),
"i18n/i18n.ts"
);

await this.fileFactory
.fromFile<TypescriptFile>(i18nFilepath)
.setImports(
[
{
packageName: "@reactionable/amplify",
modules: { initializeI18n: "" },
},
],
[
{
packageName: "@reactionable/core",
modules: { initializeI18n: "" },
},
]
)
.saveFile();
const i18nFile = await this.fileFactory.fromFile<TypescriptFile>(i18nFilepath);
i18nFile.setImports(
[
{
packageName: "@reactionable/amplify",
modules: { initializeI18n: "" },
},
],
[
{
packageName: "@reactionable/core",
modules: { initializeI18n: "" },
},
]
);

await i18nFile.saveFile();

await this.packageManagerService.installPackages(realpath, ["concurrently"], false, true);
await this.packageManagerService.updatePackageJson(realpath, {
Expand Down Expand Up @@ -242,28 +242,31 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
return this.cliService.execCmd([cmd, ...args], realpath, silent);
}

private getProjectName(realpath: string): string | undefined {
private async getProjectName(realpath: string): Promise<string | undefined> {
const projectConfigFilePath = resolve(realpath, "amplify/.config/project-config.json");

if (!this.fileService.fileExistsSync(projectConfigFilePath)) {
if (!(await this.fileService.fileExists(projectConfigFilePath))) {
return undefined;
}

return this.fileFactory.fromFile<JsonFile>(projectConfigFilePath).getData<ProjectConfig>()
?.projectName;
const projectConfigFile = await this.fileFactory.fromFile<JsonFile>(projectConfigFilePath);

return projectConfigFile.getData<ProjectConfig>()?.projectName;
}

private getBackendConfig(realpath: string): BackendConfig | undefined {
private async getBackendConfig(realpath: string): Promise<BackendConfig | undefined> {
const backendConfigFilePath = resolve(realpath, "amplify/backend/backend-config.json");
if (!this.fileService.fileExistsSync(backendConfigFilePath)) {
if (!(await this.fileService.fileExists(backendConfigFilePath))) {
return undefined;
}

return this.fileFactory.fromFile<JsonFile>(backendConfigFilePath).getData<BackendConfig>();
const backendConfigFile = await this.fileFactory.fromFile<JsonFile>(backendConfigFilePath);

return backendConfigFile.getData<BackendConfig>();
}

private async addAuth(realpath: string) {
const backendConfig = this.getBackendConfig(realpath);
const backendConfig = await this.getBackendConfig(realpath);
const isAuthAdded = !!backendConfig?.auth;

if (!isAuthAdded) {
Expand All @@ -284,8 +287,10 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
await this.execAmplifyCmd(["add", "auth"], realpath);
}

await this.fileFactory
.fromFile<TypescriptFile>(await this.getAppFilePath(realpath))
const appFile = await this.fileFactory.fromFile<TypescriptFile>(
await this.getAppFilePath(realpath)
);
appFile
.setImports([
{
packageName: "@reactionable/amplify",
Expand All @@ -295,17 +300,21 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
},
},
])
.replaceContent(/identity: undefined,.*$/m, "identity: useIdentityContextProviderProps(),")
.saveFile();
.replaceContent(/identity: undefined,.*$/m, "identity: useIdentityContextProviderProps(),");
appFile.saveFile();

await this.fileFactory
.fromFile(await this.getEntrypointFilePath(realpath))
.appendContent("import '@aws-amplify/ui/dist/style.css';", "import './index.scss';")
.saveFile();
const entrypointFile = await this.fileFactory.fromFile(
await this.getEntrypointFilePath(realpath)
);
entrypointFile.appendContent(
"import '@aws-amplify/ui/dist/style.css';",
"import './index.scss';"
);
await entrypointFile.saveFile();
}

private async addApi(realpath: string) {
const backendConfig = this.getBackendConfig(realpath);
const backendConfig = await this.getBackendConfig(realpath);
const isApiAdded = !!backendConfig?.api;

if (isApiAdded) {
Expand All @@ -329,7 +338,7 @@ export default class Amplify extends AbstractAdapterWithPackageAction implements
}

private async addHosting(realpath: string) {
const backendConfig = this.getBackendConfig(realpath);
const backendConfig = await this.getBackendConfig(realpath);
const isHostingAdded = !!backendConfig?.hosting?.amplifyhosting;

if (isHostingAdded) {
Expand Down
23 changes: 11 additions & 12 deletions src/actions/add-hosting/adapters/netlify/Netlify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class Netlify extends AbstractAdapterAction implements HostingAda
}

async isEnabled(realpath: string): Promise<boolean> {
return this.fileService.fileExistsSync(resolve(realpath, "netlify.toml"));
return this.fileService.fileExists(resolve(realpath, "netlify.toml"));
}

async run({ realpath }: AdapterActionOptions): Promise<void> {
Expand All @@ -57,17 +57,16 @@ export default class Netlify extends AbstractAdapterAction implements HostingAda

const netlifyFilePath = resolve(realpath, "netlify.toml");

await this.fileFactory
.fromFile<TomlFile>(netlifyFilePath)
.appendContent(
await this.templateService.renderTemplateFile("add-hosting/netlify/netlify.toml", {
nodeVersion: this.cliService.getNodeVersion(),
projectBranch: await this.gitService.getGitCurrentBranch(realpath, "master"),
projectPath: realpath,
projectName,
})
)
.saveFile();
const netlifyFile = await this.fileFactory.fromFile<TomlFile>(netlifyFilePath);
netlifyFile.appendContent(
await this.templateService.renderTemplateFile("add-hosting/netlify/netlify.toml", {
nodeVersion: this.cliService.getNodeVersion(),
projectBranch: await this.gitService.getGitCurrentBranch(realpath, "master"),
projectPath: realpath,
projectName,
})
);
await netlifyFile.saveFile();

// Configure netlify

Expand Down
15 changes: 7 additions & 8 deletions src/actions/add-ui-framework/adapters/UIBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ export default class UIBootstrap extends AbstractUIFrameworkAdapter {

// Import style files
this.consoleService.info("Import style files...");
const mainStyleFile = resolve(realpath, "src/index.scss");
const mainStyleFilePath = resolve(realpath, "src/index.scss");

await this.fileFactory
.fromFile(mainStyleFile)
.appendContent(
`// Import Bootstrap and its default variables
const mainStyleFile = await this.fileFactory.fromFile(mainStyleFilePath);
mainStyleFile.appendContent(
`// Import Bootstrap and its default variables
@import '~bootstrap/scss/bootstrap.scss';
`
)
.saveFile();
);
await mainStyleFile.saveFile();

this.consoleService.success(`Style files have been imported in "${mainStyleFile}"`);
this.consoleService.success(`Style files have been imported in "${mainStyleFilePath}"`);
}
}
10 changes: 5 additions & 5 deletions src/actions/add-ui-framework/adapters/UIFrameworkAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export abstract class AbstractUIFrameworkAdapter

// Add UI components to existing App components
this.consoleService.info("Add UI components to existing components...");
const appFile = await this.getAppFilePath(realpath);
await this.fileFactory
.fromFile<TypescriptFile>(appFile)
const appFilePath = await this.getAppFilePath(realpath);
const appFile = await this.fileFactory.fromFile<TypescriptFile>(appFilePath);
appFile
.setImports(
[
{
Expand All @@ -59,8 +59,8 @@ export abstract class AbstractUIFrameworkAdapter
},
]
)
.replaceContent(/ui: undefined,.*$/m, "ui: useUIContextProviderProps(),")
.saveFile();
.replaceContent(/ui: undefined,.*$/m, "ui: useUIContextProviderProps(),");
await appFile.saveFile();

this.consoleService.success("UI components have been added to existing components");
}
Expand Down
Loading