export multiple files in nrwl nx library projects into apps - nrwl-nx

New at using nx for front end development. I have the following project / lib structure
apps
- single-spa
- standalone
lib
- business
- index.tsx
The app single-spa references business. There are multiple sub folders in business at the moment. I have to manually add an entry into index.tsx for each of the component that single-spa directly OR indirectly uses
sample entry in index.txs
export * from pages/page01.js
export * from pages/page02.js
Is there an easier way to export components from lib/business ?

Related

Consuming pre-build nx library

i have multiple apps with different setup (eg next and create-react-app) and a library that includes the svg assests
the problem i am facing is that i have different webpack plugins to handle the svgs, so the result of the .svg modules transformation is different in my apps
my library is buildable and publishable, when running both apps i still see that svgs are processed with different webpack plugins and i get different results in both apps (the component for svg is exported as default in next and its exported as ReactComponent in create-react-app
Is there a way to make my apps consume the built version of the library just like its done with node_modules to include the pre-build svg assests?

How do I generate a NestJS resource in an app within an Nx workspace using the nx cli?

I want to generate a NestJS resource in my new nestjs app within an Nx workspace, similar to the way you would in a solo NextJS app using the nest generate cli command. Using the nx generate command I would expect to have to specify the app you want the resource added to, like:
nx generate #nestjs/schematics:resource **--app=haida-stories-api** --name=testresource
I tried the VS Nx Console but there are no options to specify the app target for the generate command. When I add a resource without tweaking any of the other options it just creates a new src directory in the root dir of the workspace and creates a resource unrelated to any app.
The --sourceRoot option in VS Nx Console allows me to manually enter the path to the source directory I want, but it doesn't automatically add the correct imports to the main app module.
Using the nx generate command on the command line rather than in Nx Console in VS, you can add the “project” argument:
nx g #nrwl/nest:resource <resource-name> project <app-name>
This command does generate the controller in the correct project src directory, but it doesn’t edit the app module.ts file to add the file import statement and add the resource module to the imports array, making it a route in the app.
In a pure NestJS app, if I run the following nest cli command, it automatically edits the module file:
nest generate controller test
Am I missing some documentation on the Nx cli and how it works using the VS Nx Console?

How to create python libraries and how to import it in palantir foundry

In order to generalize the python functions, I wanted to add functions to python libraries so that I can use these function across the multiple repositories. Anyone please answer the below questions.
1) How to create our own python libraries
2) how to import those libraries across multiple repositories
How to create python libraries in Palantir Foundry?
To create a new library, you can do so by creating a new repository. When prompted to initialise the repository, you should have an option that reads:
Python Library
Template for publishing a Python library package. Consuming new libraries has changed,
please read README in library repository.
The readme will contain instructions on how to publish a library. It is recommended you understand how conda publishing channels work for this.
A note, avoid using _ in the library name, since it can cause problems. - is safe to use though.
How to import a library in code authoring?
Once your library is publishing, you can add it to your conda recipe of the repository you want to consume the library in. You can find this in: transforms-python/conda_recipe/meta.yaml
Afterwards just add it to the list of under
requirements:
run:
- python
- pandas
- your-library-name
In addition to fmsf's answer, in the second step you might have to add the following content to the build.gradle of your transforms-python directory:
transformsPython {
sharedChannels "libs"
}

How to "pack" an Ember CLI component?

I'm using ember-cli and I made a custom component using ember-cli syntax & naming conventions. This is a highly reusable component and I'd like to know what is the better way to put it all into a "package" so it's easy to integrate into other projects.
My component use a .js file for the Ember.Component subclass along with a .hbs file for the template and yet another couple of .js files for the necessary Ember.View subclasses. Right now, every file is in its respective folder along with the files for the rest of my project.
How can I isolate the files related to the component and package them for reuse? In Ruby on Rails I use gems for this matter, and in jQuery I used to write plugins by extending $.fn in a single file.
Take advantage of Ember CLI addon system. It's been designed for cases like this one. The process should be easy if you are familiar with Ember CLI already. As Ember CLI addon system's been reworked in the recent past and it's API was changing it's possible that older articles or guides on this topic became out of sync.
The most comprehensive and kept in sync guide on this topic is kristianmandrup's gist Converting libraries to Ember CLI addons.
There is also an Addons tutorials section on the official Ember CLI site.

How to setup a DotNetNuke Development Environment with Source Control?

My team is developing a new DotNetNuke web application and would like to know what is recommended to setup a development environment with source control and automated builds? We would like to keep the DNN source code separate from our custom modules and extensions source code.
The DotNetNuke Compiled Module template for Visual Studio wants us to store the source code in the DesktopModules directory of the DNN source code and output to the DNN source code bin directory. Is this the recommended structure? I would rather keep the files in different locations, but then it becomes more difficult to run and debug locally as it would require an install of the module for each change. Also, how should an automated build deploy any changes?
How have others set this up? Is there a recommended best practice?
For my source control, I develop modules in their own project. This contains the module code, test code, data provider code (if applicable) and anything else. This is checked into source control like any other project. Note that the module project contains no links to a specific DNN website, and DNN references are made in the project to a common "bin" directory that references your target build. For example, in my projects folder, I have \bin460 , \bin480, \bin510, \bin520 etc. Each of these folders holds a set of binaries for a specific DNN version. That way you can build against a particular version but test against any version you like.
The problem with source-controlling a module in place in a dnn install is
- sometimes not all of the module code is easily isolated under a single parent directory
- doesn't lend well to a PA module approach
- not easy to shift the project to a different DNN Version for development or testing
- easy to inadvertently source control parts of the DNN solution, particularly with integrated VS source control solutions.
This approach compiles quickly because you're not trying to compile the entire project. For test deployment I have a build script that copies the various parts of the module into a target website. This can be done via the compile (link the build script) or just run after you've had a successful compile in a cmd window. My build script has a 'target' environment switch, so that I can say 'dnn520' to deploy the build to my test dnn520 install. Note that you need to manually create the module configuration first before this will work, but this is a one-time effort, and you can use the export feature to create your .dnn module manifest.
To build your module package, invest the time in a comprehensive script which will take the various parts from your source directory, and zip them into an install package. Keep all of the parts in your source control folder, and copy them into a temp directory, then run a command-line zip utility (I use an ancient version of pkzip) to pack it into an installable file.
The benefits of this approach is :
- separation of module code from installed code
- simple way of keeping only the module code in source control (don't have to exclude all the website code)
- ability to quickly test out modules in different dnn versions
- packaging script allows you to quickly and easily build a new version of a module for install testing/deployment
The drawbacks are
- can't use the magic green 'go' button in VS (have to manually attach debugger)
- more setup time than developing in-place
We typically stick to keeping the module code in a folder under DesktopModules and building to the website's bin directory.
In source control, we just map the individual modules, rather than the entire website. Depending on what we're working on, a module may be an entire project in source control, or we may have multiple related modules in the same project, living next to each other.
Automatically deploying changes is somewhat difficult in DNN. It's highly recommended to have a build script that packages your module into an installable form. You can then copy installable packages into the website's Install/Module folder, and get the URL /Install/Install.aspx?mode=InstallResources, which will install any packages in that folder.
In response to bduke's answer. You should, and don't want to build projects in the DesktopModules folder.
That's where all of the source code for the site out of the box goes.
That's where you modules will be "installed" and thus if someone "updates" or re-installs one, then it will be overwritten
It can make upgrading your Application far more difficult. Many developers don't understand that the idea of not touching the original source code files to modify their behavior. BECAUSE it will just be overwritten when you perform an upgrade.
If you want to build modules, create a solution folder called Modules and place your seperate project modules there.
If you want to debug them, make the target debug output point to the web\bin folder.
If you want to install/deploy them. Build it in release mode and install them through the Module/Extension filter.