”/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py” -o /tmp/labels.pdf ~/Downloads/n/*.pdf
Sincronia (from https://github.com/nuvolo/sincronia) seems to solve a lot of complaints I have about SN development.
To setup:
npm init
npm i -D @sincronia/core
npx sinc init
npx sinc dev
to start syncing projects
npx sync push
to push all scripts and overwrite what’s in SNsinc dev
and run npx sinc refresh
to pull new files
(this does not overwrite existing files)** DO NOT COMMIT .env
** it has our password in it
Note that what we are doing here is storing compiled JS in ServiceNow, which has a few implications we should be aware of:
Once using Sincronia, we will not be able to edit scripts in ServiceNow. Reading scripts in SN might be difficult or impossible too since they are compiled.
Our ServiceNow debugger (and therefore we) will debug using the compiled files, and not the original source.
Errors and line numbers coming out of SN will not match the uncompiled code. Javascript has the concept of source maps, but we cannot use it with SN (anyone that knows how to do this should share - we couldn’t make it work)
Plugins are configured in sinc.config.js
We can use the following for Babel and Typescript support:
@babel/plugin-proposal-class-properties
@babel/plugin-proposal-object-rest-spread
@babel/preset-env
@babel/preset-typescript
@sincronia/babel-plugin
@sincronia/babel-plugin-remove-modules
@sincronia/babel-preset-servicenow
@sincronia/core
@sincronia/typescript-plugin
corejs
For typescript, we can install @nuvolo/servicenow-types
to get SN types!
Then, in the configuration we setup Sincronia to process files that have an extension of .sn.js
as babel transipiled
with corejs V3 support. If a file has an extension of .sn.ts
we compile it with babel & typescript!
Our sinc.config.js
config looks like this:
module.exports = {
sourceDirectory: "src",
buildDirectory: "build",
rules: [
{
match: /\.sn\.js$/,
plugins: [
{
name: "@sincronia/babel-plugin",
options: {
plugins: [
"@sincronia/remove-modules",
"@babel/proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"
],
presets: [
"@sincronia/servicenow",
["@babel/env", {
useBuiltIns: "entry",
targets: { ie: "10" },
corejs: { version: 3 }
}]
]
}
}
]
},
{
match: /\.sn\.ts$/,
plugins: [
{
name: "@sincronia/typescript-plugin",
options: {
transpile: false,
}
},
{
name: "@sincronia/babel-plugin",
options: {
plugins: [
"@sincronia/remove-modules",
"@babel/proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"],
presets: [
"@sincronia/servicenow",
["@babel/env", {
useBuiltIns: "entry",
targets: { ie: "10" },
corejs: { version: 3 }
}],
"@babel/typescript"]
}
}
]
}
],
excludes: {},
includes: {},
tableOptions: {},
refreshInterval: 30
};
We should always make sure to start npx sinc dev
before editing files. If it is not running when files are changed
they will not be sent to the instance after the fact.
We can use npx sinc push
to push all local scripts to SN, but that will overwrite anything that is currently there.
To create new files (such as a Script Include) we first must create them in SN. Then, we can run npx sinc download
to
pull only new files (this does not overwrite any existing local files).
We should not use npx sinc download
because it will overwrite local files with what is in SN - this will result in
our nice JS code getting overwritten by the “compiled” code and will cause problems.
There are a couple of options for workflows - if we want to use git to store our scoped app code we should use 2 repositories:
If we are using update sets to push apps, there are other options for workflows - the Sincronia repository has some suggestions.