@transitive-sdk/utils-caps 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/docker.sh +1 -1
  2. package/esbuild.js +35 -17
  3. package/package.json +1 -1
package/docker.sh CHANGED
@@ -31,7 +31,7 @@ MAX_PORT=$((30080 + $OFFSET * 100))
31
31
  echo "using port offset $OFFSET, i.e., port $PORT and port range $MIN_PORT-$MAX_PORT"
32
32
 
33
33
  CAP_NAME=$(npm pkg get name)
34
- VERSION=$(npm pkg get version)
34
+ VERSION=$(node -e "console.log(require('@transitive-sdk/utils').getPackageVersionNamespace())")
35
35
  FULL_NAME=${CAP_NAME/\//.}.${VERSION}
36
36
  FULL_NAME2=${FULL_NAME//\"/}
37
37
  CONTAINER_NAME=${FULL_NAME2//@/}
package/esbuild.js CHANGED
@@ -2,13 +2,18 @@ const esbuild = require('esbuild');
2
2
  const fs = require('fs');
3
3
  const { execSync } = require('child_process');
4
4
 
5
- const { getPackageVersionNamespace } = require('@transitive-sdk/utils');
5
+ const { getLogger, getPackageVersionNamespace } = require('@transitive-sdk/utils');
6
6
 
7
7
  if (!process.env.npm_package_version || !process.env.npm_package_name) {
8
8
  console.error('This build script must be run from npm.');
9
9
  process.exit(1);
10
10
  }
11
11
 
12
+ const capability =
13
+ `${process.env.npm_package_name}@${process.env.npm_package_version}`;
14
+ const log = getLogger(capability);
15
+ log.setLevel('info');
16
+
12
17
  const entryPoints = fs.readdirSync('./web', {withFileTypes: true})
13
18
  .filter(item => !item.isDirectory())
14
19
  .filter(item => !item.isSymbolicLink())
@@ -40,24 +45,37 @@ const config = {
40
45
  // '.css': 'local-css',
41
46
  },
42
47
  plugins: [{
43
- name: 'rebuild-notify',
44
- setup(build) {
45
- build.onEnd(result => {
46
- console.log(new Date(), build.initialOptions.format,
47
- `build ended with ${result.errors.length} errors`);
48
+ /* Plugin to run tailwind and @scope the result */
49
+ name: 'tailwind-and-postprocess',
50
+ setup(build) {
51
+ build.onStart(() => {
52
+ execSync(`if (npm ls tailwindcss); then npx tailwindcss -o /tmp/tmp.css &&
53
+ (echo "@scope {"; cat /tmp/tmp.css; echo "}") > web/local.css; fi`);
54
+ })
55
+ }
56
+ }, {
57
+ name: 'rebuild-notify',
58
+ setup(build) {
59
+ build.onEnd(result => {
60
+ if (result.errors.length == 0) {
61
+ log.info(build.initialOptions.format, `build ended without errors`);
48
62
 
49
- const dir = `/tmp/caps/${process.env.npm_package_name}`;
50
- isDevelopment &&
51
- execSync(`mkdir -p ${dir} && cp -r package.json dist ${dir}`);
63
+ const dir = `/tmp/caps/${process.env.npm_package_name}`;
64
+ isDevelopment &&
65
+ execSync(`mkdir -p ${dir} && cp -r package.json dist ${dir}`);
52
66
 
53
- const metaName = [process.env.npm_package_name.replace(/\//, '-'),
54
- isDevelopment ? 'dev' : 'prod'
55
- ].join('.');
56
- fs.writeFileSync(`/tmp/${metaName}.meta.json`,
57
- JSON.stringify(result.metafile));
58
- })
59
- },
60
- }],
67
+ const metaName = [process.env.npm_package_name.replace(/\//, '-'),
68
+ isDevelopment ? 'dev' : 'prod'
69
+ ].join('.');
70
+ fs.writeFileSync(`/tmp/${metaName}.meta.json`,
71
+ JSON.stringify(result.metafile));
72
+ } else {
73
+ log.warn(build.initialOptions.format,
74
+ `build ended with ${result.errors.length} errors`);
75
+ }
76
+ })
77
+ },
78
+ }],
61
79
  };
62
80
 
63
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transitive-sdk/utils-caps",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Utilities to build and run Transitive capabilities in dev",
5
5
  "homepage": "https://transitiverobotics.com",
6
6
  "repository": {