Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sassoftware/create-react-restaf-viya-app

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sassoftware/create-react-restaf-viya-app - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

17

cli.js

@@ -17,2 +17,3 @@ #!/usr/bin/env node

let scriptTag = argv.script == null ? null : argv.script;
let installList = argv.i == null ? null : argv.installList;
let title = argv.title == null ? 'SAS/Viya Application' : argv.title;

@@ -26,2 +27,3 @@ let appName = argv.webapp == null ? 'viyademo' : argv.appname;

console.log(`scriptTag : ${scriptTag}`);
console.log(`install : ${installList}`);
console.log(`appDirectory : ${appDirectory}`);

@@ -36,9 +38,14 @@ console.log('------------------------------------------------');

}
await installPackages(appDirectory);
await installPackages(appDirectory, installList);
await updateTemplates(appDirectory, appName, scriptTag, title);
};
if
if (reactAppName === null) {
console.log('Application name required'.red);
process.exit(0);
}
run()
.then(() => {
console.log('\nApplication has been created successfully \n'.green);
console.log('\nApplication has been created successfully \n'.green);
console.log(`\nPlease configure .env file to suite your needs\n`.green);

@@ -50,7 +57,5 @@

{ Library: 'restaflib', Purpose: 'Use this for common SAS Viya usage patterns' },
{ Library: 'restaf-server', Purpose: 'Authenticate with SAS Viya and server up the app' },
{ Library: 'visual - analytics - sdk', Purpose: 'SAS Visual Analytics SDK' }
{ Library: 'restaf-server', Purpose: 'Authenticate with SAS Viya and server up the app' }
];
console.table(t);
console.log(

@@ -67,2 +72,2 @@ `\nFor development run this command:

console.log(`${err}`.red);
})
});

@@ -6,3 +6,3 @@ /*

let sh = require('shelljs');
module.exports = createReactApp = (appName) => {
module.exports = function createReactApp (appName) {
return new Promise((resolve) => {

@@ -9,0 +9,0 @@ console.log('Running create-react-app');

@@ -6,6 +6,10 @@ /*

let sh = require('shelljs');
module.exports = installPackages = (appDirectory) => {
module.exports = function installPackages (appDirectory, installList){
return new Promise((resolve) => {
console.log(`\nInstalling application dependencies in ${appDirectory}\n`);
sh.exec(`cd ${appDirectory} && yarn add rimraf @sassoftware/restaf-server @sassoftware/restaf @sassoftware/restaflib cross-env cross-spawn http-proxy-middleware && npm audit fix`, () => {
let list = `rimraf @sassoftware/restaf-server @sassoftware/restaf @sassoftware/restaflib cross-env cross-spawn http-proxy-middleware`;
if (installList !== null) {
list = list + ' ' + installList;
}
sh.exec(`cd ${appDirectory} && yarn add ${list} && npm audit fix`, () => {
console.log('\nFinished installing packages\n'.green);

@@ -16,1 +20,2 @@ resolve();

};
{
"name": "@sassoftware/create-react-restaf-viya-app",
"version": "0.3.1",
"version": "0.4.0",
"description": "a cli for creating react+restaf based apps for Viya",

@@ -5,0 +5,0 @@ "main": "cli.js",

@@ -5,22 +5,45 @@ # create-react-restaf-viya-app

This cli is an extension of create-react-app. It is designed to help developer's building react apps using restaf library and its companions:
create-react-restaf-viya-app is an extension of create-react-app. The target audience is react developers building SAS Viya Apps.
1. [restaf](https://github.com/sassoftware/restaf/wiki)
2. [restaflib](https://github.com/sassoftware/restaf/wiki)
3. [restaf-server](https://github.com/sassoftware/restaf-server/wiki)
## App Creation
## Benefits
Some of the benefits of using this cli to jump start your SAS Viya Applications
1. You retain all the benefits of using create-react-app which are well documented
2. You are automatically authenticated to the Viya Server.
3. You can start making API calls right away during development just as you would in production.
## A note on making API calls
The recommended way is to use restaf and restaflib to make the REST API calls. See the sample application created on your first creation of the application.
If for some reason[*the author can think of none*] you would prefer to hand-code the calls you can do that too. Remember that the session is authenticated using authorization_code flow and code appropriately.
---
## Creating your react application
---
Issue the command below to create the default application.
```sh
npx create-react-restaf-viya-app react-appname --webapp webapp-name --title webapp-title --script scriptTags-file
```
ex:
```sh
Example:
npx create-react-restaf-viya-app mycoolapp
```
Only the react-appname is required.
The optional parameters are:
Only the react-appname is required. The optional parameters are:

@@ -76,5 +99,14 @@ - webapp -- this is the user-friendly application name. Defaults to **viyademo**

The flow of the application on the yarn dev command is show below. Note that the application is accessing
your Viya Server during development.
The flow of the application on the yarn dev command is show below.
- Step 1 : User invokes the application at <http://localhost:5000/viyademo>
- Step 2: restaf-server authenticates with the Viya Server. The user is prompted for credentials
- Step 3a: Status of the initialization is displayed in the browser.
- Step 3b: restaf-server runs the create-react-app's **npm start** script which launches your react application in a second tab of your browser.
At this point you can view your application, edit your code and see the updated application. The session is authenticated -so you can make REST API calls to SAS Viya using restaf or any other library.
![create-react-restaf-viya](create-react-restaf-viya-app.png)

@@ -84,3 +116,3 @@

Run this command( no HMR)
Run this command. Note that the create-react-app dev server will not started.

@@ -102,3 +134,3 @@ ```sh

import React,{useContext} from 'react';
import AppContext from '../providers/AppContext';
import {AppContext} from '../providers';

@@ -115,2 +147,13 @@ let appContext = useContext(AppContext);

The logonPayload will have the following form:
```js
{
authType: 'server'
host : "your Viya hostname"
}
```
The host value is useful if you are making use of VA_SDK and/or if you are coding the REST API calls without restaf.
## Requiring restaf and restaflib in your application

@@ -117,0 +160,0 @@

@@ -101,3 +101,3 @@

return code;
}
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc