I'm familiar with writing custom PowerShell modules using the following folder structure:
Modules
| +-- WebUtils
| | +-- WebUtils.psm1
| +-- BuildUtils
| | +-- BuildUtils.psm1
Where you might import the webutils module by doing something like using module WebUtils.
I have a large ongoing project that reuses a lot of the same functionality. Right now I have a hundred or so loosely related functions in a module. The problem is that I usually only need to use 10 - 20 of them depending on the project. I would like to split up the modules in a way similar to this:
Modules
| +-- Utils
| | +-- Web
| | | +-- Web.psm1
| | +-- Build
| | | +-- Build.psm1
| | +-- Utils.psm1
Where I could call them like using module Utils.Web or something similar.
How do I go about doing this? I haven't been able to find any good examples yet. Is this a good way of organizing things?
Large modules geenrally split out into seperate modules which perform a set of related functions. A good example of this Azure or - as below - VMware PowerCLI
If you Import-Module VMware.PowerCLI it will import all the modules. But you can import an individual module and it will only import those functions/commands and any module dependencies via them being named in the .psd1 e.g if you only want VMware.VimAutomation.Core it pulls in VMware.VimAutomation.Cis.Core too
So no, not subfolders of the one module but additional related modules which can be loaded.
Related
Is there a way to create an umrella project and to specify what version of scala, or lib/s to use for each module independently?
I'd like to create a multi-module project.
Each module covers one scala version.
Each module may include submodules each of which includes some set of libs.
Non of modules interact with each other.
Each of which has it's own build.sbt file, and describes it's own set of libs.
There should be ability to build each of these modules to get a jar file.
It may have a different shape, the idea is to keep all the libs I'm playing around with in one place.
|root
|
|-|A
| |-|B
| | \build.sbt(lib1)
| |
| |-|C
| | \build.sbt(lib2)
| \build.sbt(scala_version="2.13.1")
|
|-|D
| |-|E
| | \build.sbt(lib1)
| |
| |-|F
| | \build.sbt(lib4)
| \build.sbt(scala_version="3.1.1")
|
build.sbt
I've already tried:
1. .aggregate(A,B) in the 'root' build.sbt
2. crossScalaVersions := supportedScalaVersions
3. define build.sbt files for each module independently.
The solution for IntelliJ IDEA users could be found here.
Add all the desired modules using sbt.
Press ctrl + alt + shift + s
Group(right button, then 'Change Module Names...') them.
We have our ARM templates in a build folder alongside our code. In our pipeline we publish our build folder as an artefact. We have master templates.
We want to run our ARM templates from a Release Pipeline, however our master templates can't find our linked templates, we get the following errors:
##[error]InvalidTemplateSpec: The relative path 'arm-kv/1.0.0.0/azuredeploy.json' could not be resolved. Please ensure the parent deployment references either an external URI or a template spec ID. The relativePath property cannot be used when creating a template deployment with a local file.
The folder structure of the created artefact is as follows;
Builds/
+-- ARM/
+-- parameters/
| +-- azuredeploy-rg-parameters.json ## parameters file
|
+-- arm-kv
| +-- 1.0.0.0/
| +-- azuredeploy.json ##(linked key vault template)
|
|- arm-storage
| +-- 1.0.0.0/
| +-- azuredeploy.json ##(linked storage template)
|
+-- azuredeploy-rg.json ##(main template)
What is the correct syntax for referencing the subfolder/templates? We've tried
arm-kv/1.0.0.0/azuredeploy.json (relative path)
./arm-kv/1.0.0.0/azuredeploy.json
/builds/arm/arm-kv/1.0.0.0/azuredeploy.json (the full artefact path)
When you run the task you are probably in the $(System.DefaultWorkingDirectory) context. This is the folder where artifacts are downloaded. Please check what you have exacelty there by adding a step and listing files.
Once you have it change your working directory for your ARM deployment step to $(System.DefaultWorkingDirectory)/builds/arm (it could be slightly different and this is why former step is needed to verify the path). Once you set it correctly you will get azuredeploy-rg.json in the root and all linked templates will become discoverable.
EDIT: Answered, below.
Also: If you are reading this you are probably new to web dev and you should consider using webpack for this instead of babel alone
I have what seems like a very simple problem but I can't solve it.
I have a directory structure
Project
|
+-- scripts
|
|
+-- src / src.js
|
|
+-- compiled / compiled.js
And I have been trying to get the following command to work when my terminal is located in the scripts folder.
C:\Users\me\JavaScriptProjects\survey\scripts>npx babel ./src/src.js --out-file ./compiled/compiled.js presets=env,react --watch
But it simply keeps returning:
C:\Users\me\JavaScriptProjects\survey\scripts>npx babel ./src/src.js --out-file ./compiled/compiled.js presets=env,react --watch
presets=env,react doesn't exist
I have tried permutations of removing the ./, replacing it with only /, going into src dir and replacing src/src.js with src.js and then doing ../compiled/compiled.js and many other permutations, but it just keeps saying it doesn't exist.
Even if I add both files to the same directory it's giving the same error.
Most annoying part is it was working fine yesterday.
Thanks in advance.
Solved.
The following has worked from within the src dir after trying for around an hour. I don't know what I've done differently, would love it if someone can point it out.
Thanks.
C:\Users\me\JavaScriptProjects\survey\scripts\src>npx babel src.js --out-file=../compiled/compiled.js --presets=env,react --watch
It could be that you have a babel.config.json file in the \scripts\src folder and that if you move to the \scripts folder to run npx, then it can't see the config file and so doesn't see react.
Project
|
+-- scripts
|
+-- src / src.js
+-- src / babel.config.json
|
+-- compiled / compiled.js
I am developing some server-side code in Swift on my Mac, but for eventual deployment on Linux. I have created my project structure using the Swift Package Manager. I've created a couple of XCTestCase unit tests for classes. I've noticed, however, that if I set my target product to .executable, when I run swift test I get output similar to:
Compile Swift Module 'MyProjUtilTests' (3 sources) Linking
./.build/x86_64-apple-macosx10.10/debug/MyProjUtilPackageTests.xctest/Contents/MacOS/MyProjUtilPackageTests
Undefined symbols for architecture x86_64:
"__T012MyProjUtil16PropertyListUtilCMa", referenced from:
__T017MyProjUtilTests20PropertyListUtilTestC16testReadFromFileyyF in PropertyListUtilTest.swift.o "__T012MyProjUtil3FooCMa", referenced
from:
__T017MyProjUtilTests03FooC0C07testRunD0yyFSSyKXKfu_ in FooTests.swift.o "__T012MyProjUtilAAVABycfC", referenced from:
__T017MyProjUtilTestsAAC11testExampleyyFSSyKXKfu_ in MyProjUtilTests.swift.o ld: symbol(s) not found for architecture
x86_64 :0: error: link command failed with exit code 1 (use
-v to see invocation) error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool
-f /Volumes/Untitled/SwiftDev/MyProj/MyProjUtil/.build/debug.yaml test
However, if I change my target product to .library, and run swift test it executes my tests and exits without an error. Is this a bug in the Swift Package Manager? Do I need to do something else in order to include unit tests in my executable product? Or is this the expected behavior? Can anyone shed some light on what I'm seeing here and why? Thanks!!
Yes, this is expected behavior.
You could make three targets in your Package.swift. "MyAppLibTests", "MyAppLib" and a "MyAppExec".
"MyAppLibTests" depends on "MyAppLib". "MyAppExec" also depends on "MyAppLib". And "MyAppLib" depends on whatever external dependencies you might have.
Your directory structure could look like:
+-- Package.swift
|
+-- Sources/
| |
| +-- MyAppLib/
| | ...files...
| |
| +-- MyAppLibExec/
| |
| +-- main.swift
|
+-- Tests/
|
+-- MyAppLibTests/
|
+-- MyTestCase.swift
And then in your main.swift, you would import MyAppLib; import Foundation and then perhaps parse the commandline arguments and environment variables. Pass the options into your library's main entry point. Something like MyAppMain().run(option: parsedValue, option2: parsedValue2)
Bonus: to get a commandline argument, they are in an array of Strings: Commandline.arguments. To get Environment variables, they are in a Dictionary of Strings to Strings: ProcessInfo.processInfo.environment["SOME_ENV_VAR"]
I have a Dynamic Web Project in Eclipse and was wondering if there is a way I can create a WAR and in between minify all my js and css files.
Supposing my project file structure is
iscCSM
|
|
infa9
|
|
csm--ACProxy--include--acproxy--js
| | |
| css *.js
| |
| *.css
|
|
|
view--include--js--custom
| | | |
*.html | *.js *.js
*.jsp css
|
*.css
Update
After googling I got this maven plugin Cactus but I am having problem in configuring pom.xml file to use cactus plugin as given in the same tutorial Can somebody help me which pom.xml I need to modify?
I followed the tutorial and reached the stage where string BUILD SUCCESS appears, but m unable to move forward. Please help.
Web Resource Optimizer for Java (wro4j) is what you are looking for
http://code.google.com/p/wro4j/.
It has support for js, css minifcation, with multiple minificators implementations, and also has support for less,sass, and coffeescript processor.
You can use it as:
maven plugin
standalone application
as library in yours web aplication as ServletFilter - which is nice feater to use during development.