@freestyle-sh/with-dev-server 0.1.3 → 0.1.4

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.
package/README.md CHANGED
@@ -30,6 +30,7 @@ const { vm } = await freestyle.vms.create({
30
30
  devServer: new VmDevServer({
31
31
  workdir: "/repo",
32
32
  templateRepo: TEMPLATE_REPO,
33
+ devCommand: "npm run dev",
33
34
  }),
34
35
  },
35
36
  }),
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VmSpec, VmWithInstance, VmWith } from 'freestyle-sandboxes';
2
2
 
3
- declare const createSnapshotSpec: (templateRepo: string, workdir: string) => VmSpec;
3
+ declare const createSnapshotSpec: (templateRepo: string, workdir: string, devCommand?: string) => VmSpec;
4
4
  declare class VmDevServerInstance extends VmWithInstance {
5
5
  options: {
6
6
  workdir: string;
@@ -36,11 +36,13 @@ declare class VmDevServer extends VmWith<VmDevServerInstance> {
36
36
  templateRepo?: string;
37
37
  repo?: string;
38
38
  workdir: string;
39
+ devCommand?: string;
39
40
  createInstance(): VmDevServerInstance;
40
41
  constructor(options: {
41
42
  templateRepo?: string;
42
43
  repo?: string;
43
44
  workdir?: string;
45
+ devCommand?: string;
44
46
  });
45
47
  configureSnapshotSpec(spec: VmSpec): VmSpec | Promise<VmSpec>;
46
48
  configureSpec(spec: VmSpec): VmSpec | Promise<VmSpec>;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { VmNodeJs } from '@freestyle-sh/with-nodejs';
2
2
  import { VmSpec, VmWithInstance, VmWith } from 'freestyle-sandboxes';
3
3
 
4
- const createSnapshotSpec = (templateRepo, workdir) => {
4
+ const createSnapshotSpec = (templateRepo, workdir, devCommand) => {
5
5
  const newSpec = new VmSpec({
6
6
  with: {
7
7
  nodejs: new VmNodeJs({})
@@ -24,7 +24,7 @@ const createSnapshotSpec = (templateRepo, workdir) => {
24
24
  },
25
25
  {
26
26
  name: "npm-dev",
27
- bash: "npm run dev",
27
+ bash: devCommand ?? "npm run dev",
28
28
  after: ["npm-install"],
29
29
  requires: ["npm-install"],
30
30
  workdir
@@ -50,6 +50,7 @@ done'
50
50
  return newSpec;
51
51
  };
52
52
  class VmDevServerInstance extends VmWithInstance {
53
+ options;
53
54
  constructor(options) {
54
55
  super();
55
56
  this.options = options;
@@ -136,6 +137,7 @@ class VmDevServer extends VmWith {
136
137
  templateRepo;
137
138
  repo;
138
139
  workdir;
140
+ devCommand;
139
141
  createInstance() {
140
142
  return new VmDevServerInstance({
141
143
  workdir: this.workdir
@@ -146,12 +148,13 @@ class VmDevServer extends VmWith {
146
148
  this.templateRepo = options.templateRepo;
147
149
  this.repo = options.repo;
148
150
  this.workdir = options.workdir ?? "/repo";
151
+ this.devCommand = options.devCommand;
149
152
  }
150
153
  configureSnapshotSpec(spec) {
151
154
  if (this.templateRepo) {
152
155
  const composed = this.composeSpecs(
153
156
  spec,
154
- createSnapshotSpec(this.templateRepo, this.workdir)
157
+ createSnapshotSpec(this.templateRepo, this.workdir, this.devCommand)
155
158
  );
156
159
  return composed;
157
160
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@freestyle-sh/with-dev-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "dependencies": {
6
- "freestyle-sandboxes": "^0.1.24",
7
- "@freestyle-sh/with-nodejs": "^0.2.5"
6
+ "freestyle-sandboxes": "^0.1.27",
7
+ "@freestyle-sh/with-nodejs": "^0.2.6"
8
8
  },
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",