Skip to content

Commit

Permalink
Merge pull request #635 from SUI-Components/feat/sui-app-icons
Browse files Browse the repository at this point in the history
feat(components/tool/app): Add icons command
  • Loading branch information
oegea committed Nov 15, 2023
2 parents f8fbda0 + ae7f3ef commit ef4aac7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
38 changes: 38 additions & 0 deletions components/tool/app/bin/commands/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Infra
const {reportError, runCommand} = require('../infrastructure/utils.js')

// Business logic
const {hasPackageJson, hasCapacitorConfig} = require('../domain/utils.js')

const generateIcons = () => {
console.log(`\n\n🎨 Generating icons\n\n`)

if (
runCommand('npx @capacitor/assets generate ios') === false ||
runCommand('npx @capacitor/assets generate android') === false
)
reportError(
`\n\n🚨 Something went wrong while installing dependencies 🚨\n\n`
)
else console.log(`\n\n✅ Icons successfully generated\n\n`)
}

// Command
module.exports = () => {
// If we are not placed on a webapp, we cannot continue
if (!hasPackageJson()) {
reportError(
'\n\nsui-app should be executed from a web-app project.\nPlease be sure that there is a package.json file in your current directory.\n\n'
)
return
}

// If app has already been initialized
if (!hasCapacitorConfig()) {
reportError(
`\n\nThis project has not been initialized. sui-app cannot be removed\n\n`
)
}

generateIcons()
}
5 changes: 5 additions & 0 deletions components/tool/app/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ yargs
'syncs the compiled version of the web app with the ios and android projects',
require('./commands/sync.js')
)
.command(
'icons',
'generates and transforms icons both for ios an android',
require('./commands/icons.js')
)
/* .command(
'asd [name]',
'welcome ter yargs!',
Expand Down
3 changes: 3 additions & 0 deletions components/tool/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"@capacitor/ios": "^5.5.1",
"@capgo/capacitor-native-biometric": "^5.1.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@capacitor/assets": "^3.0.1"
}
}

0 comments on commit ef4aac7

Please sign in to comment.