Aurelia: issue configuring bundled asset paths - gulp

I'm starting to build a front-end in Aurelia that is integrated into a Clojure project. I checked out some example projects and while I did find them useful for an overview, I've noticed that a lot of the out-of-the-box configurations assume the project is at root (which is understandable).
When I try to integrate this into my project and change the paths accordingly, the bundle is looking for resources in the wrong place - with a path that matches their location in the project, but not within the server's public directory.
For example, I have configured the application to bundle files that are in ./resources/public/, which is where the built files are located (I'm using several pre-processors), and these files are bundled correctly; however, when I load the page, I get the following error in my JS console:
system.src.js:4597 GET https://localhost:8443/resources/public/dist/aurelia.js 404 (Not Found)
The correct path is localhost:8443/dist/aurelia.js - I have a feeling that the /resources/public is coming from some configuration files, but if I change those the bundling breaks.
Relevant paths in the project are (truncated for brevity):
MyProject
├── gulp
│   ├── bundles.js
│   ├── paths.js
│   └── tasks
│   ├── build.js
│   ├── bundle.js
├── gulpfile.js
├── package.json
├── resources
│   ├── public
│   │   ├── config.js
│   │   ├── css
│   │   ├── dist
│   │   │   ├── app-build.js
│   │   │   └── aurelia.js
│   │   ├── fonts
│   │   ├── html
│   │   ├── img
│   │   ├── index.html
│   │   ├── js
│   │   │   ├── app.js
│   │   └── jspm_packages
│ │ ├── system.js
│ │ ├── github
│ │ └── npm
│   └── src
│   ├── fonts
│   ├── img
│   ├── js
│   ├── pug
│   └── stylus
Here are some of the pertinent configurations, trimmed for brevity:
./config.js
baseURL: "/",
...
paths: {
"*": "resources/public/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
}
Note that if I change the path for "*" (or remove it entirely), I get the following error when running gulp build:
Error on dependency parsing for npm:jquery#2.2.4/src/intro.js at
file:///Users/jszpila/Work/MyProject/resources/public/jspm_packages/npm/jquery#2.2.4/src/intro.js
MultipleErrors:
compiler-parse-input:47:1: Unexpected token End of File
compiler-parse-input:47:1: Unexpected token End of File
compiler-parse-input:47:1: Unexpected token End of File
./package.json
"jspm": {
"directories": {
"baseURL": "resources/public"
},
"devDependencies": {
"aurelia-animator-css": "npm:aurelia-animator-css#^1.0.0-beta.1.1.2",
"aurelia-bootstrapper": "npm:aurelia-bootstrapper#^1.0.0-beta.1.1.4",
"aurelia-fetch-client": "npm:aurelia-fetch-client#^1.0.0-beta.1.1.1",
...
}
},
./gulp/bundles.js
"bundles": {
"dist/app-build": {
"includes": [
"[**/*.js]",
"**/*.html!text",
"**/*.css!text"
],
"options": {
"inject": true,
"minify": true,
"depCache": true,
"rev": false
}
},
"dist/aurelia": {
"includes": [
...
"fetch",
"jquery"
],
"options": {
"inject": true,
"minify": true,
"depCache": false,
"rev": false
}
}
}
./gulp/tasks/bundle.js
var config = {
force: true,
baseURL: './resources/public/',
configPath: './resources/public/config.js',
bundles: bundles.bundles
};
So I think it's safe to assume that this incorrect path is coming from one of those configurations; however, they are correct for the tooling - just not the bundle. Can I configure the bundling tool paths and the application tool paths separately, or am I overlooking a misconfiguration?
Thanks in advance for any help!

Related

Access JSON values using Chef and test-kitchen

I'm new to Chef and Test-kitchen and I'm trying to use random JSON file as attribute or environment (preferably attribute), but unfortunately I can't access the JSON values from the recipes.
I'm using the following directory structure:
uat
├── attributes
│   ├── dev.json
│   ├── .kitchen
│   │   └── logs
│   │   └── kitchen.log
│   └── prod.json
├── Berksfile
├── Berksfile.lock
├── chefignore
├── environments
│   ├── dev.json
│   └── prod.json
├── Gemfile
├── Gemfile.lock
├── .kitchen
│   ├── default-windows.yml
│   └── logs
│   ├── default-windows.log
│   └── kitchen.log
├── .kitchen.yml
├── metadata.rb
└── recipes
   ├── default.rb
   ├── prep.rb
   └── service_install.rb
This is the .kitchen.yml:
---
driver:
name: machine
username: sample_user
password: sample_pass
hostname: 192.168.1.102
port: 5985
provisioner:
name: chef_zero
json_attributes: true
environments_path: 'environments/dev'
platforms:
- name: windows
suites:
- name: default
run_list:
- recipe[uat::default]
This is the dev.json:
{
"groupID": "Project-name",
"directoryName": "sample_folder",
"environmentType": "UAT",
}
This is the recipe prep.rb :
directory "C:/Users/test/#{node['directoryName']}" do
recursive true
action :create
end
If I create something.rb in attributes folder and with content: default['directoryName'] = 'sample_folder', it works like a charm, but I need to use a JSON file which to store parameters company wide.
Could you please help me find what I'm doing wrong.
So a couple of issues. First, the environments_path points at a folder, not the specific file, so that should just be environments/. Second, it has to be an actual environment object, see https://docs.chef.io/environments.html#json for a description of the schema. Third, you would need to actually apply the environment to the test node:
provisioner:
# Other stuff ...
client_rb:
chef_environment: dev

Ansible, role not found error

I try to play following playbook against localhost to provision Vagrant machine
---
- hosts: all
become: yes
roles:
- base
- jenkins
I have cloned necessary roles from github and they resides in a relative path roles/{role name}
Executing following command: ansible-playbook -i "localhost," -c local playbook.yml outputs this error:
==> default: ERROR! the role 'geerlingguy.java' was not found in /home/vagrant/provisioning/roles:/home/vagrant/provisioning:/etc/ansible/roles:/home/vagrant/provisioning/roles
==> default:
==> default: The error appears to have been in '/home/vagrant/provisioning/roles/jenkins/meta/main.yml': line 3, column 5, but may
==> default: be elsewhere in the file depending on the exact syntax problem.
==> default:
==> default: The offending line appears to be:
==> default:
==> default: dependencies:
==> default: - geerlingguy.java
==> default: ^ here
I cloned the missing dependency from github, and tried to reside it in relative path of roles/java and roles/geerlingguy/java, but either didn't solve the problem, and error stays the same.
I want to keep all roles locally in the synced provisioning folder, without using ansible-galaxy runtime, to make the provisioning method as self contained as possible.
Here is the provision folder structure as it is now
.
├── playbook.yml
└── roles
├── base
│   └── tasks
│   └── main.yml
├── java
│   ├── defaults
│   │   └── main.yml
│   ├── meta
│   │   └── main.yml
│   ├── README.md
│   ├── tasks
│   │   ├── main.yml
│   │   ├── setup-Debian.yml
│   │   ├── setup-FreeBSD.yml
│   │   └── setup-RedHat.yml
│   ├── templates
│   │   └── java_home.sh.j2
│   ├── tests
│   │   └── test.yml
│   └── vars
│   ├── Debian.yml
│   ├── Fedora.yml
│   ├── FreeBSD.yml
│   ├── RedHat.yml
│   ├── Ubuntu-12.04.yml
│   ├── Ubuntu-14.04.yml
│   └── Ubuntu-16.04.yml
└── jenkins
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   ├── main.yml
│   ├── plugins.yml
│   ├── settings.yml
│   ├── setup-Debian.yml
│   └── setup-RedHat.yml
├── templates
│   └── basic-security.groovy
├── tests
│   ├── requirements.yml
│   ├── test-http-port.yml
│   ├── test-jenkins-version.yml
│   ├── test-plugins-with-pinning.yml
│   ├── test-plugins.yml
│   ├── test-prefix.yml
│   └── test.yml
└── vars
├── Debian.yml
└── RedHat.yml
You should install or clone all required roles in the /roles folder (or in the system folder)
ansible-galaxy install -p ROLES_PATH geerlingguy.java
should fix this specific problem.
However, the best practice should be the use of a requirements.yml file where you require all the needed roles and then install them with ansible-galaxy directly in your playbook.
- name: run ansible galaxy
local_action: command ansible-galaxy install -r requirements.yml --ignore-errors
Simple symbolic link works like a charm without any installations:
$ mkdir /home/USER/ansible && ln -s /home/USER/GIT/ansible-root/roles
Here is the solution: the required path for the role is roles/geerlingguy.java/, not roles/geerlingguy/java/

Using Jekyll's Collection relative_directory for organizing pages/collections

I thought that setting the relative_directory (Jekyll Collection Docs) (github PR) property being set would help me keep my files organized without compromising my desired output, but it seems to be ignored/not used for producing files. I don't want my collections to be in the root directory, because I find it confusing to have ~10 collection folders adjacent to _assets, _data, _includes, _layouts, and others.
Fixes or alternative solutions are welcomed, as long as long as the output is the same, and my pages are in their own directory, without needing to put permalink front-matter on every single page.
_config.yaml
collections:
root:
relative_directory: '_pages/root'
output: true
permalink: /:path.html
root-worthy:
relative_directory: '_pages/root-worthy'
output: true
permalink: /:path.html
docs:
relative_directory: '_pages/docs'
output: true
permalink: /docs/:path.html
Directory Structure:
├── ...
├── _layouts
├── _pages
│   ├── root
│   │ ├── about.html
│   │ └── contact.html
│   ├── root_worthy
│   │ ├── quickstart.html
│   │ └── seo-worthy-page.html
│   └── docs
│   ├── errors.html
│   └── api.html
├── _posts
└── index.html
Desired output:
├── ...
├── _site
│   ├── about.html
│   ├── contact.html
│   ├── quickstart.html
│   ├── seo-worthy-page.html
│   └── docs
│   ├── errors.html
│   └── api.html
└── ...
It seems that the PR you mention is still not merged.
For 3.1.6 and next 3.2, jekyll code is still :
#relative_directory ||= "_#{label}"
But the requester made a plugin that looks like this :
_plugins/collection_relative_directory.rb
module Jekyll
class Collection
def relative_directory
#relative_directory ||= (metadata['relative_directory'] && site.in_source_dir(metadata['relative_directory']) || "_#{label}")
end
end
end

How do I get Lazybones to process sub-templates?

Playing with Lazybones for the first time. I've put together a simple project which attempts to include a single sub-template.
Here is the project structure:
.
├── build.gradle
├── gradlew
├── gradlew.bat
├── README.md
└── templates
├── groovy-lambda
│   ├── build.gradle
│   ├── lazybones.groovy
│   ├── README.md
│   ├── src
│   │   ├── main
│   │   │   ├── groovy
│   │   │   │   └── .retain
│   │   │   └── resources
│   │   │   └── .retain
│   │   └── test
│   │   ├── groovy
│   │   │   └── .retain
│   │   └── resources
│   │   └── .retain
│   └── VERSION
└── subtmpl-groovy-lambda-main-class
├── GroovyLambdaMainClass.groovy
├── lazybones.groovy
└── VERSION
And I'm including the sub-template like so
lazybones {
template "groovy-lambda" includes "groovy-lambda-main-class"
}
The sub-template gets packaged in the main artefact archive:
.
├── build.gradle
├── .lazybones
│   ├── groovy-lambda-main-class-template-1.0-SNAPSHOT.zip
│   └── stored-params.properties
├── README.md
└── src
├── main
│   ├── groovy
│   └── resources
└── test
├── groovy
└── resources
However the sub-template never gets processed at template execution time i.e. the sub-templates lazybones.groovy script doesn't seem to get run.
The whole project is available here on GitHub. To reproduce the issue do:
git#github.com:eddgrant/lazybones-template-aws-groovy-lambda.git
cd lazybones-template-aws-groovy-lambda.git
./gradlew installAllTemplates
cd /tmp
lazybones --verbose create groovy-lambda 1.0-SNAPSHOT groovy-lambda
I'm probably missing something trivial but can't quite figure it out. Most grateful for any pointers.
Everything is working as expected. Sub templates are only used by the lazybones generate command, which in turn works only once you have created a Lazybones-based project.
The classic example is something like a Grails or Rails project in which you would use the generate command to create new controllers or domain classes.

Ignoring test files in same dirs as source files in gulp globs

I have folders with test and source files mixed together
├── module-x
│   ├── module-x.hbs
│   ├── module-x.js
│   ├── module-x.less
│   └── module-x.test.js
├── module-y
│   ├── module-y.hbs
│   ├── module-y.js
│   ├── module-y.less
│   └── module-y.test.js
I have gulp running browserSync with some globs to watch files and reload the app. I can't find a glob that will watch the .js files but ignore the .test.js ones
This ones worked for me
glob: path.resolve(root + "/**/!(*.test).js"),