Skip to content

Commit

Permalink
feat: sasjs create SASONLY template #68
Browse files Browse the repository at this point in the history
  • Loading branch information
saadjutt01 committed Sep 8, 2020
1 parent 4d8b726 commit c49b45d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cli.js
Expand Up @@ -286,7 +286,7 @@ function invalidAppType(){
}

function processCreateParameters(parameters) {
const supportedTypes = ['react', 'angular', 'minimal']
const supportedTypes = ['react', 'angular', 'minimal', 'sasonly']
let params = { projectName: undefined, appType: undefined }
switch (parameters.length){
case 1: // sasjs create
Expand Down
40 changes: 40 additions & 0 deletions src/config-sasonly.json
@@ -0,0 +1,40 @@
{
"folders": [
{
"folderName": "sasjs",
"files": [],
"subFolders": [
{
"folderName": "db"
},
{
"folderName": "build"
},
{
"folderName": "macros"
},
{
"folderName": "services",
"files": [],
"subFolders": [
{
"folderName": "common",
"files": [
{
"fileName": "appinit.sas",
"content": "/**\n @file appinit.sas\n @brief Initialisation service - runs on app startup\n @details This is always the first service called when the app is opened.\n\n <h4> Dependencies </h4>\n\n**/\n\nproc sql;\ncreate table areas as select distinct area\n from sashelp.springs;\n%webout(OPEN)\n%webout(OBJ,areas)\n%webout(CLOSE)\n"
}
]
}
]
}
]
}
],
"config": {
"cmnMacros": ["macros"],
"cmnServices": ["services/common"],
"useMacroCore": true,
"targets": []
}
}
11 changes: 6 additions & 5 deletions src/sasjs-create/index.js
Expand Up @@ -18,8 +18,9 @@ import {
import chalk from 'chalk'

export async function create(parentFolderName = '.', appType = '') {
const config = await getConfiguration(path.join(__dirname, '../config.json'))
const fileStructure = await getFileStructure()
const configPath = appType === 'sasonly' ? '../config-sasonly.json' : '../config.json'
const config = await getConfiguration(path.join(__dirname, configPath))
const fileStructure = await getFileStructure(appType === 'sasonly')
console.log(chalk.greenBright('Creating folders and files...'))
if (parentFolderName !== '.') {
await createFolder(path.join(process.projectDir, parentFolderName))
Expand Down Expand Up @@ -58,12 +59,12 @@ export async function create(parentFolderName = '.', appType = '') {
})
}

if (!appType) {
if (!appType || appType === 'sasonly') {
await setupNpmProject(parentFolderName)
}
await setupGitIgnore(parentFolderName)
}

async function getFileStructure() {
return await getFolders()
async function getFileStructure(sasOnly = false) {
return await getFolders(sasOnly)
}
5 changes: 3 additions & 2 deletions src/utils/config-utils.js
Expand Up @@ -112,8 +112,9 @@ export async function saveLocalRcFile(content) {
await createFile(path.join(projectRoot, '.sasjsrc'), content)
}

export async function getFolders() {
const config = await readFile(path.join(__dirname, '../config.json'))
export async function getFolders(sasOnly = false) {
const configPath = sasOnly ? '../config-sasonly.json' : '../config.json'
const config = await readFile(path.join(__dirname, configPath))
if (config) {
const configJson = JSON.parse(config)
return Promise.resolve(configJson.folders)
Expand Down

0 comments on commit c49b45d

Please sign in to comment.