How do I programatically read the version of a currently running oclif app? - oclif

This title says it all: How do I programatically read the version of a currently running oclif command-line app (from within the app)?

Luckily answer was pretty simple:
export default class Foo extends Command {
async run() {
console.log(this.config.version);
}
}

Related

Adding installation parameters to a contentful App

Struggling to find a working example or a document that explains how to set contentful app installation params. I can see how to get them from the SDK but settings them i cant.
any help is much appreciated.
Most likely your app has a Config Location which means you are building UI that will be shown to the user during and after installation of your app. In this location, there is an SDK method called sdk.app.onConfigure. This method takes a function which will return an object which is called targetState.
targetState documentation can be found here.
Let's take a React Config app as an example where we will set {foo: 'bar'} as our installation parameters:
export default class Config extends Component<ConfigProps, ConfigState> {
constructor(props: ConfigProps) {
super(props);
// letting the SDK know we have a configuration function which will
// return `targetState`
props.sdk.app.onConfigure(() => this.onConfigure());
}
// This method will be called when a user clicks on "Install"
// or "Save" on the configuration screen.
onConfigure = async () => {
// the object returned here is what Contentful calls `targetState`.
// it is simply a configuration object set when the app is installed or updated
return {
parameters: { installation: { foo: 'bar' } }
};
};
In the example above, when a user hits "Install" or "Save" on the app's Config location, the installation parameter object of {foo: 'bar'} will be saved and can then be accessed in other app locations via the SDK.
On the off chance you are purely using the API to create or modify an AppInstallation, you can use the Content Management API to update the app's parameters as described in the documentation here.
Late answer but i also struggled with it. I found a tutorial here:
https://dev.to/wiommi/how-i-built-a-contentful-app-combined-with-commerce-js-iii-33fo
They are added manually in ConfigScreen.tsx
You need to add them to your interface
export interface AppInstallationParameters {}
fx:
export interface AppInstallationParameters {
apiKey?: string;
projectId?: string;
}
And then set them manually with fx.
setParameters({ ...parameters, [PARAMETERNAME]: [PARAMETERVALUE] });

How to use an angular module that does not support Universal with an angular/cli app using SSR

Hey everyone I have been building an Angular app that is using Universal with SSR for a while not and every so often I would include a module that would cause the server to fail silently and never knew why, last night I figured out it was because the module I tried to include (ngx-editor) does not support Universal.
Is there a way for me to include a module such as ngx-editor that does not support Universal in my application? Or do I have to find one that supports Universal?
Thanks a lot in advance.
You could try not calling this module's components depending on the platform, e.g. by checking the platform dynamically in your code ( https://angular.io/api/common/isPlatformBrowser)
import {isPlatformBrowser} from "#angular/common";
//...
constructor(#Inject(PLATFORM_ID) private platformId: Object)
{
if(isPlatformBrowser(this.platformId))
{
//call module's methods/components...
}
else { /*server side*/ }
}
You may also need to modify your server module (app.server.module.ts) to not include modules that do not support angular-universal

Nothing happens when running a simple Groovy Ratpack script

I'm new to groovy and ratpack. I have read that i can simply put my entire application in a file and run it like a simple groovy script groovy filename.groovy. When I run one example script nothing seems to happen and pointing the browser to localhost:5050 has no effect... I'm sure I'm missing something big...What I have to do in order to get started?
Do I need to start the application in some way, other than running the script?
#GrabResolver("https://oss.jfrog.org/artifactory/repo")
#Grab("io.ratpack:ratpack-groovy:0.9.0-SNAPSHOT")
import static ratpack.groovy.Groovy.*
ratpack {
handlers {
get {
response.send "Hi!"
}
assets "public"
}
}
Use latest versions of ratpack (0.9.2[released today] or 0.9.1). They seem to work the way you are trying to use.
#GrabResolver("https://oss.jfrog.org/artifactory/repo")
#Grab("io.ratpack:ratpack-groovy:0.9.2")
import static ratpack.groovy.Groovy.*
ratpack {
handlers {
get {
response.send "Hi!"
}
//assets "public" //Not required if there is no asset to refer to
}
}
You can also run the script from groovyConsole to start the server.
Running as a script is a good starting point. Using ratpack for projects, I suppose a good staring point will be to use gradle as well, with something like below as the project structure.
-- client
-- server
|_ src
|_ ratpack
|_ ratpack.groovy
|_ build.gradle
You can effectively use ratpack-groovy plugin in gradle if you are already familiar with gradle and opting to use it. Here is an example app of using ratpack gradle plugin in a ratpack app. Another example where you can see usage of ratpack (server), mongo (db) and AngularJS (as client)

Problems using an installclass in a web setup for a web site

I am trying to create a web setup for my web site, and I want to use an installer class to do some custom stuff. I am using VS 2010, and the web site and installer is .NET 3.5.
I have added reference to the installer class project output in the Install section under Custom Actions:
I have also set /targetdir="[TARGETDIR]/" on the CustomActionData for this action.
The InstallScript project is a standard class library (dll).
There is a public class that inherits from Installer class. It overrides the Install method as I have seen been done in several online examples:
using System.Collections;
using System.Windows.Forms;
namespace InstallScript
{
public class MyWebInstaller : System.Configuration.Install.Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var targetDir = Context.Parameters["targetdir"];
if(targetDir==null) targetDir = "No TARGETDIR!";
MessageBox.Show("TARGETDIR:\t" + targetDir);
}
}
}
I would think there should be shown a message box here som time during the install, but it seems like it is never called. No error is shown either. The setup just runs through as if this code was never called.
Anyone have idea of what is wrong?
OK, I found out what was missing.
You need to specify the class with the class attribute RunInstaller(true) for the setup to pick up and actually run the code.
So the class needs to be declared like this:
[System.ComponentModel.RunInstaller(true)]
public class MyWebInstaller : System.Configuration.Install.Installer
{
...

Secure in Playframework

I'm trying to install secure module in playframework, I tried with http://www.playframework.org/documentation/1.2.2/secure but Secure.class isn't found
import models.Task;
import play.mvc.Controller;
import play.mvc.With;
public class Application extends Controller {
#With(Secure.class)
public static void index() {
Please any help please
You have to add the module in the conf/dependencies.yml
It should look lie that :
# Application dependencies
require:
- play
- secure
Then you have to type the following command
play dependencies your_play_app
I have the following in dependencies.yml:
require:
- play -> secure
And I believe you have to protect the whole controller, using #With(Secure.class) before the class definition:
#With(Secure.class)
public class Application extends Controller {
...
}
As above, and if you're using Eclipse make sure you run play eclipsify to bring the Secure module (and it's classes) into your project.
Add the following dependency in your conf/dependencies.yml
require:
- play -> secure
Then, use the commands to install secure module
play dpes
If you use eclipse, remember the use the command after "play deps" command
play ec
This command will make the module visible in your eclipse

Resources