@temporalio/create 0.15.0 → 0.17.0
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/cli.js +1 -1
- package/lib/create-project.js +64 -68
- package/lib/create-project.js.map +1 -1
- package/lib/helpers/fetch-samples.js +3 -10
- package/lib/helpers/fetch-samples.js.map +1 -1
- package/lib/helpers/get-error-code.js +1 -5
- package/lib/helpers/get-error-code.js.map +1 -1
- package/lib/helpers/git.js +10 -17
- package/lib/helpers/git.js.map +1 -1
- package/lib/helpers/install.js +15 -21
- package/lib/helpers/install.js.map +1 -1
- package/lib/helpers/is-online.js +8 -15
- package/lib/helpers/is-online.js.map +1 -1
- package/lib/helpers/is-writeable.js +5 -12
- package/lib/helpers/is-writeable.js.map +1 -1
- package/lib/helpers/make-dir.js +3 -10
- package/lib/helpers/make-dir.js.map +1 -1
- package/lib/helpers/samples.js +23 -35
- package/lib/helpers/samples.js.map +1 -1
- package/lib/helpers/strip-snip-comments.js +8 -15
- package/lib/helpers/strip-snip-comments.js.map +1 -1
- package/lib/helpers/subprocess.js +5 -11
- package/lib/helpers/subprocess.js.map +1 -1
- package/lib/helpers/validate-pkg.js +3 -10
- package/lib/helpers/validate-pkg.js.map +1 -1
- package/lib/index.js +43 -50
- package/lib/index.js.map +1 -1
- package/lib/pkg.js +4 -11
- package/lib/pkg.js.map +1 -1
- package/package.json +4 -4
package/cli.js
CHANGED
package/lib/create-project.js
CHANGED
|
@@ -1,56 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createApp = exports.DownloadError = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/create-app.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const subprocess_1 = require("./helpers/subprocess");
|
|
25
|
-
const fetch_samples_1 = require("./helpers/fetch-samples");
|
|
26
|
-
class DownloadError extends Error {
|
|
2
|
+
import retry from 'async-retry';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import chalkTemplate from 'chalk-template';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import prompts from 'prompts';
|
|
7
|
+
import { access, rm, readFile } from 'fs/promises';
|
|
8
|
+
import { downloadAndExtractSample, downloadAndExtractRepo, getRepoInfo, hasSample, checkForPackageJson, } from './helpers/samples.js';
|
|
9
|
+
import { makeDir } from './helpers/make-dir.js';
|
|
10
|
+
import { tryGitInit } from './helpers/git.js';
|
|
11
|
+
import { install, updateNodeVersion, replaceTemporalVersion } from './helpers/install.js';
|
|
12
|
+
import { testIfThisComputerIsOnline } from './helpers/is-online.js';
|
|
13
|
+
import { isWriteable } from './helpers/is-writeable.js';
|
|
14
|
+
import { getErrorCode } from './helpers/get-error-code.js';
|
|
15
|
+
import { stripSnipComments } from './helpers/strip-snip-comments.js';
|
|
16
|
+
import { fetchSamples } from './helpers/fetch-samples.js';
|
|
17
|
+
export class DownloadError extends Error {
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample, samplePath, }) {
|
|
19
|
+
export async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample, samplePath, }) {
|
|
30
20
|
let repoInfo;
|
|
31
21
|
let repoUrl;
|
|
32
|
-
const isOnline = await
|
|
22
|
+
const isOnline = await testIfThisComputerIsOnline();
|
|
33
23
|
if (!isOnline) {
|
|
34
|
-
console.error(`Unable to reach ${
|
|
24
|
+
console.error(`Unable to reach ${chalk.bold(`github.com`)}. Perhaps you are not connected to the internet?`);
|
|
35
25
|
process.exit(1);
|
|
36
26
|
}
|
|
37
27
|
try {
|
|
38
28
|
repoUrl = new URL(sample);
|
|
39
29
|
}
|
|
40
30
|
catch (error) {
|
|
41
|
-
if (
|
|
31
|
+
if (getErrorCode(error) !== 'ERR_INVALID_URL') {
|
|
42
32
|
console.error(error);
|
|
43
33
|
process.exit(1);
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
36
|
if (repoUrl) {
|
|
47
37
|
if (repoUrl.origin !== 'https://github.com') {
|
|
48
|
-
console.error(`Invalid URL: ${
|
|
38
|
+
console.error(`Invalid URL: ${chalk.red(`"${sample}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);
|
|
49
39
|
process.exit(1);
|
|
50
40
|
}
|
|
51
41
|
try {
|
|
52
|
-
repoInfo = await
|
|
53
|
-
await
|
|
42
|
+
repoInfo = await getRepoInfo(repoUrl, samplePath);
|
|
43
|
+
await checkForPackageJson(repoInfo);
|
|
54
44
|
}
|
|
55
45
|
catch (e) {
|
|
56
46
|
console.error(e);
|
|
@@ -58,34 +48,34 @@ async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample,
|
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
else if (sample !== '__internal-testing-retry') {
|
|
61
|
-
const found = await
|
|
51
|
+
const found = await hasSample(sample);
|
|
62
52
|
if (!found) {
|
|
63
|
-
console.error(`Could not locate a sample named ${
|
|
64
|
-
const samples = await
|
|
53
|
+
console.error(`Could not locate a sample named ${chalk.red(`"${sample}"`)}. It could be due to the following:\n`, `1. Your spelling of sample ${chalk.red(`"${sample}"`)} might be incorrect.\n`, `2. You might not be connected to the internet.\n`);
|
|
54
|
+
const samples = await fetchSamples();
|
|
65
55
|
console.error(`Available samples:\n\n${samples.join('\n')}\n`);
|
|
66
56
|
process.exit(1);
|
|
67
57
|
}
|
|
68
58
|
}
|
|
69
|
-
const root =
|
|
70
|
-
if (!(await
|
|
59
|
+
const root = path.resolve(appPath);
|
|
60
|
+
if (!(await isWriteable(path.dirname(root)))) {
|
|
71
61
|
console.error('The application path is not writable, please check folder permissions and try again.');
|
|
72
62
|
console.error('It is likely you do not have write permissions for this folder.');
|
|
73
63
|
process.exit(1);
|
|
74
64
|
}
|
|
75
|
-
const appName =
|
|
76
|
-
console.log(`Creating a new Temporal project in ${
|
|
65
|
+
const appName = path.basename(root);
|
|
66
|
+
console.log(`Creating a new Temporal project in ${chalk.green(root)}/`);
|
|
77
67
|
console.log();
|
|
78
68
|
let directoryExists = true;
|
|
79
69
|
try {
|
|
80
|
-
await
|
|
70
|
+
await access(root);
|
|
81
71
|
}
|
|
82
72
|
catch (error) {
|
|
83
|
-
const code =
|
|
73
|
+
const code = getErrorCode(error);
|
|
84
74
|
if (code === 'ENOENT') {
|
|
85
75
|
directoryExists = false;
|
|
86
76
|
}
|
|
87
77
|
else if (code === 'EACCES') {
|
|
88
|
-
console.error(`Unable to access directory ${
|
|
78
|
+
console.error(`Unable to access directory ${chalk.bold(root + '/')} (Error: permission denied)`);
|
|
89
79
|
process.exit(1);
|
|
90
80
|
}
|
|
91
81
|
else {
|
|
@@ -93,23 +83,23 @@ async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample,
|
|
|
93
83
|
}
|
|
94
84
|
}
|
|
95
85
|
if (directoryExists) {
|
|
96
|
-
const res = await (
|
|
86
|
+
const res = await prompts({
|
|
97
87
|
type: 'confirm',
|
|
98
88
|
name: 'shouldReplace',
|
|
99
|
-
message: `Directory ${
|
|
89
|
+
message: `Directory ${chalk.green(root + '/')} already exists. Would you like to replace it?`,
|
|
100
90
|
});
|
|
101
91
|
if (!res.shouldReplace) {
|
|
102
92
|
console.error('Exiting. You can re-run this command with a different project name.');
|
|
103
93
|
process.exit(1);
|
|
104
94
|
}
|
|
105
|
-
await
|
|
95
|
+
await rm(root, { recursive: true, force: true, maxRetries: 5 });
|
|
106
96
|
}
|
|
107
97
|
try {
|
|
108
|
-
await
|
|
98
|
+
await makeDir(root);
|
|
109
99
|
}
|
|
110
100
|
catch (error) {
|
|
111
|
-
if (
|
|
112
|
-
console.error(`Unable to cd into directory ${
|
|
101
|
+
if (getErrorCode(error) === 'EACCES') {
|
|
102
|
+
console.error(`Unable to cd into directory ${chalk.bold(root + '/')} (Error: permission denied)`);
|
|
113
103
|
process.exit(1);
|
|
114
104
|
}
|
|
115
105
|
else {
|
|
@@ -122,19 +112,19 @@ async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample,
|
|
|
122
112
|
try {
|
|
123
113
|
if (repoInfo) {
|
|
124
114
|
const repoInfo2 = repoInfo;
|
|
125
|
-
console.log(`Downloading files from repo ${
|
|
115
|
+
console.log(`Downloading files from repo ${chalk.cyan(sample)}. This might take a moment.`);
|
|
126
116
|
console.log();
|
|
127
|
-
await (
|
|
117
|
+
await retry(() => downloadAndExtractRepo(root, repoInfo2), {
|
|
128
118
|
retries: 3,
|
|
129
119
|
});
|
|
130
120
|
}
|
|
131
121
|
else {
|
|
132
|
-
console.log(`Downloading files for sample ${
|
|
122
|
+
console.log(`Downloading files for sample ${chalk.cyan(sample)}. This might take a moment.`);
|
|
133
123
|
console.log();
|
|
134
|
-
await (
|
|
124
|
+
await retry(() => downloadAndExtractSample(root, sample), {
|
|
135
125
|
retries: 3,
|
|
136
126
|
});
|
|
137
|
-
await
|
|
127
|
+
await stripSnipComments(root);
|
|
138
128
|
}
|
|
139
129
|
}
|
|
140
130
|
catch (reason) {
|
|
@@ -146,34 +136,40 @@ async function createApp({ appPath, useYarn, gitInit, temporalioVersion, sample,
|
|
|
146
136
|
}
|
|
147
137
|
console.log('Installing packages. This might take a couple of minutes.');
|
|
148
138
|
console.log();
|
|
149
|
-
await
|
|
139
|
+
await updateNodeVersion({ root });
|
|
150
140
|
if (temporalioVersion) {
|
|
151
|
-
await
|
|
141
|
+
await replaceTemporalVersion({ root, useYarn, temporalioVersion });
|
|
152
142
|
}
|
|
153
|
-
await
|
|
143
|
+
await install({ root, useYarn });
|
|
154
144
|
console.log();
|
|
155
|
-
if (await
|
|
145
|
+
if (await tryGitInit(root, gitInit)) {
|
|
156
146
|
console.log('Initialized a git repository.');
|
|
157
147
|
}
|
|
158
|
-
const messageFile =
|
|
148
|
+
const messageFile = path.join(root, '.post-create');
|
|
159
149
|
console.log();
|
|
160
|
-
console.log(`${
|
|
150
|
+
console.log(`${chalk.green('Success!')} Created project ${chalk.bold(appName)} at:`);
|
|
161
151
|
console.log();
|
|
162
|
-
console.log(
|
|
152
|
+
console.log(chalk.bold(appPath + '/'));
|
|
163
153
|
console.log();
|
|
164
154
|
try {
|
|
165
|
-
await
|
|
166
|
-
const message = await
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
|
|
155
|
+
await access(messageFile);
|
|
156
|
+
const message = await readFile(messageFile, 'utf8');
|
|
157
|
+
// Hack for creating a TemplateStringsArray
|
|
158
|
+
// Required by chalk-template
|
|
159
|
+
class MockTemplateString extends Array {
|
|
160
|
+
constructor(raw) {
|
|
161
|
+
super();
|
|
162
|
+
this.raw = raw;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
console.log(chalkTemplate(new MockTemplateString([message])));
|
|
166
|
+
await rm(messageFile);
|
|
170
167
|
}
|
|
171
168
|
catch (error) {
|
|
172
|
-
const code =
|
|
169
|
+
const code = getErrorCode(error);
|
|
173
170
|
if (code !== 'ENOENT') {
|
|
174
171
|
throw error;
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
174
|
}
|
|
178
|
-
exports.createApp = createApp;
|
|
179
175
|
//# sourceMappingURL=create-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-project.js","sourceRoot":"","sources":["../src/create-project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-project.js","sourceRoot":"","sources":["../src/create-project.ts"],"names":[],"mappings":"AAAA,wIAAwI;AACxI,OAAO,KAAK,MAAM,aA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G,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEpD,2CAA2C;QAC3C,6BAA6B;QAC7B,MAAM,kBAAmB,SAAQ,KAAK;YACpC,YAA4B,GAAa;gBACvC,KAAK,EAAE,CAAC;gBADkB,QAAG,GAAH,GAAG,CAAU;YAEzC,CAAC;SACF;QACD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC;KACvB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,IAAI,KAAK,QAAQ,EAAE;YACrB,MAAM,KAAK,CAAC;SACb;KACF;AACH,CAAC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchSamples = void 0;
|
|
7
|
-
const got_1 = __importDefault(require("got"));
|
|
1
|
+
import got from 'got';
|
|
8
2
|
const SAMPLE_REPO_CONTENTS = 'https://api.github.com/repos/temporalio/samples-typescript/contents/';
|
|
9
|
-
async function fetchSamples() {
|
|
3
|
+
export async function fetchSamples() {
|
|
10
4
|
let response;
|
|
11
5
|
try {
|
|
12
6
|
// https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md#response-1
|
|
13
|
-
response = await (
|
|
7
|
+
response = await got(SAMPLE_REPO_CONTENTS);
|
|
14
8
|
}
|
|
15
9
|
catch (error) {
|
|
16
10
|
throw new Error(`Unable to reach github.com`);
|
|
@@ -20,5 +14,4 @@ async function fetchSamples() {
|
|
|
20
14
|
.filter((file) => file.type === 'dir' && file.name !== 'test' && !file.name.startsWith('.'))
|
|
21
15
|
.map(({ name }) => name);
|
|
22
16
|
}
|
|
23
|
-
exports.fetchSamples = fetchSamples;
|
|
24
17
|
//# sourceMappingURL=fetch-samples.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-samples.js","sourceRoot":"","sources":["../../src/helpers/fetch-samples.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-samples.js","sourceRoot":"","sources":["../../src/helpers/fetch-samples.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,oBAAoB,GAAG,sEAAsE,CAAC;AAOpG,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,QAAQ,CAAC;IAEb,IAAI;QACF,sFAAsF;QACtF,QAAQ,GAAG,MAAM,GAAG,CAAC,oBAAoB,CAAC,CAAC;KAC5C;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAC/C;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAW,CAAC;IAElD,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAC3F,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getErrorCode = void 0;
|
|
4
|
-
function getErrorCode(error) {
|
|
1
|
+
export function getErrorCode(error) {
|
|
5
2
|
if (error.code !== undefined && typeof error.code === 'string') {
|
|
6
3
|
return error.code;
|
|
7
4
|
}
|
|
@@ -9,5 +6,4 @@ function getErrorCode(error) {
|
|
|
9
6
|
return '';
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.getErrorCode = getErrorCode;
|
|
13
9
|
//# sourceMappingURL=get-error-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-error-code.js","sourceRoot":"","sources":["../../src/helpers/get-error-code.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-error-code.js","sourceRoot":"","sources":["../../src/helpers/get-error-code.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAK,KAAuB,CAAC,IAAI,KAAK,SAAS,IAAI,OAAQ,KAAuB,CAAC,IAAI,KAAK,QAAQ,EAAE;QACpG,OAAQ,KAAuB,CAAC,IAAI,CAAC;KACtC;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC"}
|
package/lib/helpers/git.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.tryGitInit = void 0;
|
|
7
1
|
/* eslint-disable no-empty */
|
|
8
2
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/git.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { rm } from 'fs/promises';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import prompts from 'prompts';
|
|
13
7
|
const NOT_A_GIT_REPOSITORY_STATUS_CODE = 128;
|
|
14
8
|
function isInGitRepository() {
|
|
15
9
|
try {
|
|
16
|
-
|
|
10
|
+
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
|
17
11
|
return true;
|
|
18
12
|
}
|
|
19
13
|
catch (error) {
|
|
@@ -29,7 +23,7 @@ function isInGitRepository() {
|
|
|
29
23
|
const HG_ERROR_STATUS_CODE = 255;
|
|
30
24
|
function isInMercurialRepository() {
|
|
31
25
|
try {
|
|
32
|
-
|
|
26
|
+
execSync('hg --cwd . root', { stdio: 'ignore' });
|
|
33
27
|
return true;
|
|
34
28
|
}
|
|
35
29
|
catch (error) {
|
|
@@ -43,17 +37,17 @@ function isInMercurialRepository() {
|
|
|
43
37
|
}
|
|
44
38
|
}
|
|
45
39
|
}
|
|
46
|
-
async function tryGitInit(root, useGit) {
|
|
40
|
+
export async function tryGitInit(root, useGit) {
|
|
47
41
|
if (useGit === false) {
|
|
48
42
|
return false;
|
|
49
43
|
}
|
|
50
44
|
let didInit = false;
|
|
51
|
-
const exec = (command) =>
|
|
45
|
+
const exec = (command) => execSync(command, { stdio: 'ignore', cwd: root });
|
|
52
46
|
try {
|
|
53
47
|
// If user didn't include --use-git, and they might be in an existing repo,
|
|
54
48
|
// ask before `git init`ing
|
|
55
49
|
if (useGit === undefined && (isInGitRepository() || isInMercurialRepository())) {
|
|
56
|
-
const res = await (
|
|
50
|
+
const res = await prompts({
|
|
57
51
|
type: 'confirm',
|
|
58
52
|
name: 'shouldInit',
|
|
59
53
|
message: `Would you like me to initialize a git repository for the project?`,
|
|
@@ -72,12 +66,11 @@ async function tryGitInit(root, useGit) {
|
|
|
72
66
|
catch (e) {
|
|
73
67
|
if (didInit) {
|
|
74
68
|
try {
|
|
75
|
-
await (
|
|
69
|
+
await rm(path.join(root, '.git'), { recursive: true, force: true });
|
|
76
70
|
}
|
|
77
71
|
catch (_) { }
|
|
78
72
|
}
|
|
79
73
|
return false;
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
|
-
exports.tryGitInit = tryGitInit;
|
|
83
76
|
//# sourceMappingURL=git.js.map
|
package/lib/helpers/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/helpers/git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/helpers/git.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,yIAAyI;AACzI,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAE7C,SAAS,iBAAiB;IACxB,IAAI;QACF,QAAQ,CAAC,qCAAqC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAU,EAAE;QACnB,IAAI,KAAK,CAAC,MAAM,KAAK,gCAAgC,EAAE;YACrD,OAAO,KAAK,CAAC;SACd;aAAM;YACL,qDAAqD;YACrD,OAAO,IAAI,CAAC;SACb;KACF;AACH,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,SAAS,uBAAuB;IAC9B,IAAI;QACF,QAAQ,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAU,EAAE;QACnB,qFAAqF;QACrF,IAAI,KAAK,CAAC,MAAM,KAAK,oBAAoB,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YACjF,OAAO,KAAK,CAAC;SACd;aAAM;YACL,qDAAqD;YACrD,OAAO,IAAI,CAAC;SACb;KACF;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,MAAgB;IAC7D,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpF,IAAI;QACF,2EAA2E;QAC3E,2BAA2B;QAC3B,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,iBAAiB,EAAE,IAAI,uBAAuB,EAAE,CAAC,EAAE;YAC9E,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,YAAY;gBAClB,OAAO,EAAE,mEAAmE;aAC7E,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;gBACnB,OAAO,KAAK,CAAC;aACd;SACF;QAED,IAAI,CAAC,UAAU,CAAC,CAAC;QACjB,OAAO,GAAG,IAAI,CAAC;QAEf,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAE7B,IAAI,CAAC,YAAY,CAAC,CAAC;QACnB,IAAI,CAAC,wDAAwD,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,OAAO,EAAE;YACX,IAAI;gBACF,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;aACrE;YAAC,OAAO,CAAC,EAAE,GAAE;SACf;QACD,OAAO,KAAK,CAAC;KACd;AACH,CAAC"}
|
package/lib/helpers/install.js
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceTemporalVersion = exports.updateNodeVersion = exports.install = void 0;
|
|
4
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/install.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
3
|
+
import { spawn } from './subprocess.js';
|
|
4
|
+
import { isUrlOk } from './samples.js';
|
|
8
5
|
/**
|
|
9
6
|
* Spawn a package manager installation with either Yarn or NPM.
|
|
10
7
|
*
|
|
11
8
|
* @returns A Promise that resolves once the installation is finished.
|
|
12
9
|
*/
|
|
13
|
-
function install({ root, useYarn }) {
|
|
10
|
+
export function install({ root, useYarn }) {
|
|
14
11
|
const npm = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
|
|
15
12
|
const command = useYarn ? 'yarn' : npm;
|
|
16
|
-
return
|
|
13
|
+
return spawn(command, ['install'], {
|
|
17
14
|
cwd: root,
|
|
18
15
|
stdio: 'inherit',
|
|
19
16
|
env: { ...process.env, ADBLOCK: '1', DISABLE_OPENCOLLECTIVE: '1' },
|
|
20
17
|
});
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
async function updateNodeVersion({ root }) {
|
|
19
|
+
export async function updateNodeVersion({ root }) {
|
|
24
20
|
const currentNodeVersion = +process.versions.node.split('.')[0];
|
|
25
21
|
const versionAlreadyInPackageJson = 16;
|
|
26
22
|
const minimumValidVersion = 14;
|
|
27
23
|
if (currentNodeVersion >= minimumValidVersion && currentNodeVersion !== versionAlreadyInPackageJson) {
|
|
28
24
|
const packageName = `@tsconfig/node${currentNodeVersion}`;
|
|
29
25
|
const fileName = `${root}/package.json`;
|
|
30
|
-
const packageExists = await
|
|
26
|
+
const packageExists = await isUrlOk(`https://registry.npmjs.org/${packageName}`);
|
|
31
27
|
if (packageExists) {
|
|
32
|
-
let fileString = (await
|
|
33
|
-
await
|
|
28
|
+
let fileString = (await readFile(fileName)).toString();
|
|
29
|
+
await writeFile(fileName, fileString.replace(`@tsconfig/node${versionAlreadyInPackageJson}`, packageName));
|
|
34
30
|
const tsconfigJson = `${root}/tsconfig.json`;
|
|
35
|
-
fileString = (await
|
|
36
|
-
await
|
|
31
|
+
fileString = (await readFile(tsconfigJson)).toString();
|
|
32
|
+
await writeFile(tsconfigJson, fileString.replace(`@tsconfig/node${versionAlreadyInPackageJson}`, packageName));
|
|
37
33
|
}
|
|
38
|
-
await
|
|
34
|
+
await writeFile(`${root}/.nvmrc`, currentNodeVersion.toString());
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
async function replaceTemporalVersion({ root, temporalioVersion }) {
|
|
37
|
+
export async function replaceTemporalVersion({ root, temporalioVersion }) {
|
|
43
38
|
const fileName = `${root}/package.json`;
|
|
44
|
-
const packageJson = JSON.parse(await
|
|
39
|
+
const packageJson = JSON.parse(await readFile(fileName, 'utf8'));
|
|
45
40
|
packageJson.dependencies.temporalio = temporalioVersion;
|
|
46
|
-
await
|
|
41
|
+
await writeFile(fileName, JSON.stringify(packageJson));
|
|
47
42
|
}
|
|
48
|
-
exports.replaceTemporalVersion = replaceTemporalVersion;
|
|
49
43
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/helpers/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/helpers/install.ts"],"names":[],"mappings":"AAAA,6IAA6I;AAC7I,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAYvC;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAe;IACpD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,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AC,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,iBAAiB,2BAA2B,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;SAChH;QAED,MAAM,SAAS,CAAC,GAAG,IAAI,SAAS,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC;KAClE;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAe;IACnF,MAAM,QAAQ,GAAG,GAAG,IAAI,eAAe,CAAC;IAExC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACjE,WAAW,CAAC,YAAY,CAAC,UAAU,GAAG,iBAAiB,CAAC;IACxD,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
package/lib/helpers/is-online.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.testIfThisComputerIsOnline = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/is-online.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import dns from 'dns';
|
|
4
|
+
import { URL } from 'url';
|
|
11
5
|
// Look for any proxy the user might have configured on their machine
|
|
12
6
|
function getProxy() {
|
|
13
7
|
if (process.env.https_proxy) {
|
|
14
8
|
return process.env.https_proxy;
|
|
15
9
|
}
|
|
16
10
|
try {
|
|
17
|
-
const httpsProxy =
|
|
11
|
+
const httpsProxy = execSync('npm config get https-proxy').toString().trim();
|
|
18
12
|
return httpsProxy !== 'null' ? httpsProxy : undefined;
|
|
19
13
|
}
|
|
20
14
|
catch (e) {
|
|
21
15
|
return;
|
|
22
16
|
}
|
|
23
17
|
}
|
|
24
|
-
function testIfThisComputerIsOnline() {
|
|
18
|
+
export function testIfThisComputerIsOnline() {
|
|
25
19
|
return new Promise((resolve) => {
|
|
26
|
-
|
|
20
|
+
dns.lookup('github.com', (registryErr) => {
|
|
27
21
|
if (!registryErr) {
|
|
28
22
|
return resolve(true);
|
|
29
23
|
}
|
|
@@ -33,15 +27,14 @@ function testIfThisComputerIsOnline() {
|
|
|
33
27
|
if (!proxy) {
|
|
34
28
|
return resolve(false);
|
|
35
29
|
}
|
|
36
|
-
const { hostname } = new
|
|
30
|
+
const { hostname } = new URL(proxy);
|
|
37
31
|
if (!hostname) {
|
|
38
32
|
return resolve(false);
|
|
39
33
|
}
|
|
40
|
-
|
|
34
|
+
dns.lookup(hostname, (proxyErr) => {
|
|
41
35
|
resolve(proxyErr == null);
|
|
42
36
|
});
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
|
-
exports.testIfThisComputerIsOnline = testIfThisComputerIsOnline;
|
|
47
40
|
//# sourceMappingURL=is-online.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-online.js","sourceRoot":"","sources":["../../src/helpers/is-online.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-online.js","sourceRoot":"","sources":["../../src/helpers/is-online.ts"],"names":[],"mappings":"AAAA,+IAA+I;AAC/I,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,qEAAqE;AACrE,SAAS,QAAQ;IACf,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;KAChC;IAED,IAAI;QACF,MAAM,UAAU,GAAG,QAAQ,CAAC,4BAA4B,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAC5E,OAAO,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;KACvD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO;KACR;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,EAAE;YACvC,IAAI,CAAC,WAAW,EAAE;gBAChB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;aACtB;YAED,uEAAuE;YACvE,yDAAyD;YACzD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,EAAE;gBACV,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;aACvB;YAED,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,EAAE;gBACb,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;aACvB;YAED,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAChC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isWriteable = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/is-writeable.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
async function isWriteable(directory) {
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { getErrorCode } from './get-error-code.js';
|
|
4
|
+
export async function isWriteable(directory) {
|
|
11
5
|
try {
|
|
12
|
-
await
|
|
6
|
+
await fs.promises.access(directory, (fs.constants || fs).W_OK);
|
|
13
7
|
return true;
|
|
14
8
|
}
|
|
15
9
|
catch (error) {
|
|
16
|
-
if (
|
|
10
|
+
if (getErrorCode(error) === 'EACCES') {
|
|
17
11
|
return false;
|
|
18
12
|
}
|
|
19
13
|
else {
|
|
@@ -21,5 +15,4 @@ async function isWriteable(directory) {
|
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
17
|
}
|
|
24
|
-
exports.isWriteable = isWriteable;
|
|
25
18
|
//# sourceMappingURL=is-writeable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-writeable.js","sourceRoot":"","sources":["../../src/helpers/is-writeable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-writeable.js","sourceRoot":"","sources":["../../src/helpers/is-writeable.ts"],"names":[],"mappings":"AAAA,kJAAkJ;AAClJ,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,SAAiB;IACjD,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;aAAM;YACL,MAAM,KAAK,CAAC;SACb;KACF;AACH,CAAC"}
|
package/lib/helpers/make-dir.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeDir = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/make-dir.ts
|
|
8
|
-
|
|
9
|
-
async function makeDir(root, options = { recursive: true }) {
|
|
10
|
-
await
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
export async function makeDir(root, options = { recursive: true }) {
|
|
4
|
+
await fs.promises.mkdir(root, options);
|
|
11
5
|
}
|
|
12
|
-
exports.makeDir = makeDir;
|
|
13
6
|
//# sourceMappingURL=make-dir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-dir.js","sourceRoot":"","sources":["../../src/helpers/make-dir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"make-dir.js","sourceRoot":"","sources":["../../src/helpers/make-dir.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,OAAO,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE;IACvE,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
package/lib/helpers/samples.js
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadAndExtractSample = exports.downloadAndExtractRepo = exports.hasSample = exports.checkForPackageJson = exports.getRepoInfo = exports.isUrlOk = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/examples.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const pipeline =
|
|
17
|
-
async function isUrlOk(url) {
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import got from 'got';
|
|
4
|
+
import tar from 'tar';
|
|
5
|
+
import { Stream } from 'stream';
|
|
6
|
+
import { promisify } from 'util';
|
|
7
|
+
import { rm, readdir } from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { getErrorCode } from './get-error-code.js';
|
|
10
|
+
const pipeline = promisify(Stream.pipeline);
|
|
11
|
+
export async function isUrlOk(url) {
|
|
18
12
|
let res;
|
|
19
13
|
try {
|
|
20
|
-
res = await
|
|
14
|
+
res = await got.head(url);
|
|
21
15
|
}
|
|
22
16
|
catch (e) {
|
|
23
17
|
return false;
|
|
24
18
|
}
|
|
25
19
|
return res.statusCode === 200;
|
|
26
20
|
}
|
|
27
|
-
exports.isUrlOk = isUrlOk;
|
|
28
21
|
// https://stackoverflow.com/a/3561711/627729
|
|
29
22
|
function escapeRegex(s) {
|
|
30
23
|
// eslint-disable-next-line no-useless-escape
|
|
31
24
|
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
32
25
|
}
|
|
33
|
-
async function getRepoInfo(url, samplePath) {
|
|
26
|
+
export async function getRepoInfo(url, samplePath) {
|
|
34
27
|
const [, username, name, t, _branch, ...file] = url.pathname.split('/');
|
|
35
28
|
const filePath = samplePath ? samplePath.replace(/^\//, '') : file.join('/');
|
|
36
29
|
// Support repos whose entire purpose is to be a Temporal sample, e.g.
|
|
@@ -40,7 +33,7 @@ async function getRepoInfo(url, samplePath) {
|
|
|
40
33
|
let infoResponse;
|
|
41
34
|
try {
|
|
42
35
|
// https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md#response-1
|
|
43
|
-
infoResponse = await (
|
|
36
|
+
infoResponse = await got(repo);
|
|
44
37
|
}
|
|
45
38
|
catch (error) {
|
|
46
39
|
throw new Error(`Unable to fetch ${repo}`);
|
|
@@ -62,45 +55,40 @@ async function getRepoInfo(url, samplePath) {
|
|
|
62
55
|
throw new Error(`Unable to parse URL: ${url} and sample path: ${samplePath}`);
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
|
-
|
|
66
|
-
async function checkForPackageJson({ username, name, branch, filePath }) {
|
|
58
|
+
export async function checkForPackageJson({ username, name, branch, filePath }) {
|
|
67
59
|
const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;
|
|
68
60
|
const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;
|
|
69
61
|
const fullUrl = contentsUrl + packagePath + `?ref=${branch}`;
|
|
70
62
|
if (!(await isUrlOk(fullUrl))) {
|
|
71
|
-
throw new Error(`Could not locate a package.json at ${
|
|
63
|
+
throw new Error(`Could not locate a package.json at ${chalk.red(`"${fullUrl}"`)}.\nPlease check that the repository is a Temporal TypeScript SDK template and try again.`);
|
|
72
64
|
}
|
|
73
65
|
}
|
|
74
|
-
|
|
75
|
-
function hasSample(name) {
|
|
66
|
+
export function hasSample(name) {
|
|
76
67
|
return isUrlOk(`https://api.github.com/repos/temporalio/samples-typescript/contents/${encodeURIComponent(name)}/package.json`);
|
|
77
68
|
}
|
|
78
|
-
|
|
79
|
-
async function downloadAndExtractRepo(root, { username, name, branch, filePath }) {
|
|
69
|
+
export async function downloadAndExtractRepo(root, { username, name, branch, filePath }) {
|
|
80
70
|
const archiveUrl = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;
|
|
81
71
|
const archivePath = `${name}-${branch}${filePath ? `/${filePath}` : ''}`;
|
|
82
|
-
await pipeline(
|
|
83
|
-
const files = await
|
|
72
|
+
await pipeline(got.stream(archiveUrl), tar.extract({ cwd: root, strip: filePath ? filePath.split('/').length + 1 : 1 }, [archivePath]));
|
|
73
|
+
const files = await readdir(root);
|
|
84
74
|
const pipelineFailed = files.length === 0;
|
|
85
75
|
if (pipelineFailed) {
|
|
86
76
|
console.error('We were unable to download and extract the provided project.\n', `Archive URL: ${archiveUrl}\n`, `Archive path: ${archivePath}\n`, `Sometimes this is due to the repo name changing. If that's the case, try using the new repo URL.`);
|
|
87
77
|
process.exit(1);
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
|
-
|
|
91
|
-
async function downloadAndExtractSample(root, name) {
|
|
80
|
+
export async function downloadAndExtractSample(root, name) {
|
|
92
81
|
if (name === '__internal-testing-retry') {
|
|
93
82
|
throw new Error('This is an internal sample for testing the CLI.');
|
|
94
83
|
}
|
|
95
|
-
await pipeline(
|
|
84
|
+
await pipeline(got.stream('https://codeload.github.com/temporalio/samples-typescript/tar.gz/main'), tar.extract({ cwd: root, strip: 2 }, [`samples-typescript-main/${name}`]));
|
|
96
85
|
try {
|
|
97
|
-
await
|
|
86
|
+
await rm(path.join(root, `.npmrc`));
|
|
98
87
|
}
|
|
99
88
|
catch (e) {
|
|
100
|
-
if (
|
|
89
|
+
if (getErrorCode(e) !== 'ENOENT') {
|
|
101
90
|
throw e;
|
|
102
91
|
}
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
|
-
exports.downloadAndExtractSample = downloadAndExtractSample;
|
|
106
94
|
//# sourceMappingURL=samples.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"samples.js","sourceRoot":"","sources":["../../src/helpers/samples.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"samples.js","sourceRoot":"","sources":["../../src/helpers/samples.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,KA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MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IAC1C,IAAI,cAAc,EAAE;QAClB,OAAO,CAAC,KAAK,CACX,gEAAgE,EAChE,gBAAgB,UAAU,IAAI,EAC9B,iBAAiB,WAAW,IAAI,EAChC,kGAAkG,CACnG,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAY,EAAE,IAAY;IACvE,IAAI,IAAI,KAAK,0BAA0B,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;IAED,MAAM,QAAQ,CACZ,GAAG,CAAC,MAAM,CAAC,uEAAuE,CAAC,EACnF,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC,CAC1E,CAAC;IAEF,IAAI;QACF,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAChC,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.stripSnipComments = void 0;
|
|
7
|
-
const glob_1 = __importDefault(require("glob"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const promises_1 = require("fs/promises");
|
|
10
|
-
async function stripSnipComments(root) {
|
|
11
|
-
const files = glob_1.default.sync('**/*.ts', { cwd: root });
|
|
1
|
+
import glob from 'glob';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
4
|
+
export async function stripSnipComments(root) {
|
|
5
|
+
const files = glob.sync('**/*.ts', { cwd: root });
|
|
12
6
|
await Promise.all(files.map(async (file) => {
|
|
13
|
-
const filePath =
|
|
14
|
-
const fileString = await
|
|
15
|
-
await
|
|
7
|
+
const filePath = path.join(root, file);
|
|
8
|
+
const fileString = await readFile(filePath, 'utf8');
|
|
9
|
+
await writeFile(filePath, fileString.replace(/ *\/\/ @@@SNIP.+\n/g, ''));
|
|
16
10
|
}));
|
|
17
11
|
}
|
|
18
|
-
exports.stripSnipComments = stripSnipComments;
|
|
19
12
|
//# sourceMappingURL=strip-snip-comments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip-snip-comments.js","sourceRoot":"","sources":["../../src/helpers/strip-snip-comments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strip-snip-comments.js","sourceRoot":"","sources":["../../src/helpers/strip-snip-comments.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitOnChild = exports.spawn = exports.ChildProcessError = void 0;
|
|
4
1
|
// https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
|
|
5
|
-
|
|
6
|
-
class ChildProcessError extends Error {
|
|
2
|
+
import { spawn as origSpawn } from 'child_process';
|
|
3
|
+
export class ChildProcessError extends Error {
|
|
7
4
|
constructor(message, code, signal) {
|
|
8
5
|
super(message);
|
|
9
6
|
this.code = code;
|
|
@@ -11,11 +8,10 @@ class ChildProcessError extends Error {
|
|
|
11
8
|
this.name = 'ChildProcessError';
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
async function spawn(command, args, options) {
|
|
11
|
+
export async function spawn(command, args, options) {
|
|
16
12
|
try {
|
|
17
13
|
// Workaround @types/node - avoid choosing overloads per options.stdio variants
|
|
18
|
-
await waitOnChild(options === undefined ? (
|
|
14
|
+
await waitOnChild(options === undefined ? origSpawn(command, args) : origSpawn(command, args || [], options));
|
|
19
15
|
}
|
|
20
16
|
catch (err) {
|
|
21
17
|
if (err instanceof ChildProcessError) {
|
|
@@ -25,8 +21,7 @@ async function spawn(command, args, options) {
|
|
|
25
21
|
throw err;
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
async function waitOnChild(child) {
|
|
24
|
+
export async function waitOnChild(child) {
|
|
30
25
|
return new Promise((resolve, reject) => {
|
|
31
26
|
child.on('exit', (code, signal) => {
|
|
32
27
|
if (code === 0) {
|
|
@@ -39,5 +34,4 @@ async function waitOnChild(child) {
|
|
|
39
34
|
child.on('error', reject);
|
|
40
35
|
});
|
|
41
36
|
}
|
|
42
|
-
exports.waitOnChild = waitOnChild;
|
|
43
37
|
//# sourceMappingURL=subprocess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../src/helpers/subprocess.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../src/helpers/subprocess.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAgB,KAAK,IAAI,SAAS,EAAgB,MAAM,eAAe,CAAC;AAE/E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAK1C,YAAY,OAAe,EAAkB,IAAmB,EAAkB,MAAqB;QACrG,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,SAAI,GAAJ,IAAI,CAAe;QAAkB,WAAM,GAAN,MAAM,CAAe;QAJvF,SAAI,GAAG,mBAAmB,CAAC;IAM3C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe,EAAE,IAA4B,EAAE,OAAsB;IAC/F,IAAI;QACF,+EAA+E;QAC/E,MAAM,WAAW,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;KAC/G;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,iBAAiB,EAAE;YACpC,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;YACtB,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;SACjB;QACD,MAAM,GAAG,CAAC;KACX;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAmB;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YAChC,IAAI,IAAI,KAAK,CAAC,EAAE;gBACd,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,MAAM,CAAC,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;aAC/D;QACH,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateNpmName = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/helpers/validate-pkg.ts
|
|
8
|
-
|
|
9
|
-
function validateNpmName(name) {
|
|
10
|
-
const nameValidation = (
|
|
2
|
+
import validateProjectName from 'validate-npm-package-name';
|
|
3
|
+
export function validateNpmName(name) {
|
|
4
|
+
const nameValidation = validateProjectName(name);
|
|
11
5
|
if (nameValidation.validForNewPackages) {
|
|
12
6
|
return { valid: true };
|
|
13
7
|
}
|
|
@@ -16,5 +10,4 @@ function validateNpmName(name) {
|
|
|
16
10
|
problems: [...(nameValidation.errors || []), ...(nameValidation.warnings || [])],
|
|
17
11
|
};
|
|
18
12
|
}
|
|
19
|
-
exports.validateNpmName = validateNpmName;
|
|
20
13
|
//# sourceMappingURL=validate-pkg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pkg.js","sourceRoot":"","sources":["../../src/helpers/validate-pkg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-pkg.js","sourceRoot":"","sources":["../../src/helpers/validate-pkg.ts"],"names":[],"mappings":"AAAA,kJAAkJ;AAClJ,OAAO,mBAAmB,MAAM,2BAA2B,CAAC;AAE5D,MAAM,UAAU,eAAe,CAAC,IAAY;IAI1C,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,cAAc,CAAC,mBAAmB,EAAE;QACtC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACxB;IAED,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;KACjF,CAAC;AACJ,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.run = void 0;
|
|
7
1
|
// Modified from: https://github.com/vercel/next.js/blob/2425f4703c4c6164cecfdb6aa8f80046213f0cc6/packages/create-next-app/index.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const program = new
|
|
19
|
-
.version(
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import dedent from 'dedent';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import prompts from 'prompts';
|
|
7
|
+
import checkForUpdate from 'update-check';
|
|
8
|
+
import { createApp } from './create-project.js';
|
|
9
|
+
import { validateNpmName } from './helpers/validate-pkg.js';
|
|
10
|
+
import { fetchSamples } from './helpers/fetch-samples.js';
|
|
11
|
+
import packageJson from './pkg.js';
|
|
12
|
+
const program = new Command(packageJson.name)
|
|
13
|
+
.version(packageJson.version, '-v, --version', 'Print the version and exit')
|
|
20
14
|
.arguments('[project-directory]')
|
|
21
|
-
.usage(`${
|
|
22
|
-
.option('-s, --sample <name|github-url>',
|
|
15
|
+
.usage(`${chalk.green('[project-directory]')} [options]`)
|
|
16
|
+
.option('-s, --sample <name|github-url>', dedent `
|
|
23
17
|
Which sample to bootstrap the project with. You can use the name of a sample
|
|
24
18
|
from https://github.com/temporalio/samples-typescript or use a GitHub URL.
|
|
25
19
|
The URL can have a branch and/or subdirectory—for example:
|
|
26
20
|
https://github.com/temporalio/samples-typescript/tree/next/hello-world
|
|
27
21
|
`)
|
|
28
|
-
.option('--sample-path <path-to-sample>',
|
|
22
|
+
.option('--sample-path <path-to-sample>', dedent `
|
|
29
23
|
In a rare case, your GitHub URL might contain a branch name with
|
|
30
24
|
a slash (e.g. bug/fix-1) and the path to the sample (e.g. foo/bar).
|
|
31
25
|
In this case, you must specify the path to the sample separately:
|
|
32
26
|
--sample-path foo/bar
|
|
33
27
|
`)
|
|
34
|
-
.option('-l, --list-samples',
|
|
28
|
+
.option('-l, --list-samples', dedent `
|
|
35
29
|
Print available sample projects and exit
|
|
36
30
|
`)
|
|
37
|
-
.option('--use-yarn',
|
|
31
|
+
.option('--use-yarn', dedent `
|
|
38
32
|
Use yarn instead of npm
|
|
39
33
|
`)
|
|
40
|
-
.option('--git-init',
|
|
34
|
+
.option('--git-init', dedent `
|
|
41
35
|
Initialize a git repository
|
|
42
36
|
`)
|
|
43
|
-
.option('--no-git-init',
|
|
37
|
+
.option('--no-git-init', dedent `
|
|
44
38
|
Skip git repository initialization
|
|
45
39
|
`)
|
|
46
|
-
.option('--temporalio-version <version>',
|
|
40
|
+
.option('--temporalio-version <version>', dedent `
|
|
47
41
|
Specify which version of the temporalio npm package to use
|
|
48
42
|
`)
|
|
49
43
|
.allowUnknownOption()
|
|
@@ -52,7 +46,7 @@ let opts;
|
|
|
52
46
|
async function start() {
|
|
53
47
|
opts = program.opts();
|
|
54
48
|
if (opts.listSamples) {
|
|
55
|
-
const samples = await
|
|
49
|
+
const samples = await fetchSamples();
|
|
56
50
|
console.log(`Available samples:\n\n${samples.join('\n')}\n`);
|
|
57
51
|
return;
|
|
58
52
|
}
|
|
@@ -61,13 +55,13 @@ async function start() {
|
|
|
61
55
|
projectPath = projectPath.trim();
|
|
62
56
|
}
|
|
63
57
|
if (!projectPath) {
|
|
64
|
-
const res = await (
|
|
58
|
+
const res = await prompts({
|
|
65
59
|
type: 'text',
|
|
66
60
|
name: 'path',
|
|
67
61
|
message: 'What is your project named?',
|
|
68
62
|
initial: 'my-temporal',
|
|
69
63
|
validate: (name) => {
|
|
70
|
-
const validation =
|
|
64
|
+
const validation = validateNpmName(path.basename(path.resolve(name)));
|
|
71
65
|
if (validation.valid) {
|
|
72
66
|
return true;
|
|
73
67
|
}
|
|
@@ -81,27 +75,27 @@ async function start() {
|
|
|
81
75
|
if (!projectPath) {
|
|
82
76
|
console.error();
|
|
83
77
|
console.error('Please specify the project directory:');
|
|
84
|
-
console.error(` ${
|
|
78
|
+
console.error(` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`);
|
|
85
79
|
console.error();
|
|
86
80
|
console.error('For example:');
|
|
87
|
-
console.error(` ${
|
|
81
|
+
console.error(` ${chalk.cyan(program.name())} ${chalk.green('my-temporal-project')}`);
|
|
88
82
|
console.error();
|
|
89
|
-
console.error(`Run ${
|
|
83
|
+
console.error(`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`);
|
|
90
84
|
process.exit(1);
|
|
91
85
|
}
|
|
92
|
-
const resolvedProjectPath =
|
|
93
|
-
const projectName =
|
|
94
|
-
const { valid, problems } =
|
|
86
|
+
const resolvedProjectPath = path.resolve(projectPath);
|
|
87
|
+
const projectName = path.basename(resolvedProjectPath);
|
|
88
|
+
const { valid, problems } = validateNpmName(projectName);
|
|
95
89
|
if (!valid) {
|
|
96
|
-
console.error(`Could not create a project called ${
|
|
97
|
-
problems?.forEach((p) => console.error(` ${
|
|
90
|
+
console.error(`Could not create a project called ${chalk.red(`"${projectName}"`)} because of npm naming restrictions:`);
|
|
91
|
+
problems?.forEach((p) => console.error(` ${chalk.red.bold('*')} ${p}`));
|
|
98
92
|
process.exit(1);
|
|
99
93
|
}
|
|
100
94
|
let sample = opts.sample;
|
|
101
95
|
if (!sample) {
|
|
102
|
-
const samples = await
|
|
96
|
+
const samples = await fetchSamples();
|
|
103
97
|
const choices = samples.map((sample) => ({ title: sample, value: sample }));
|
|
104
|
-
const res = await (
|
|
98
|
+
const res = await prompts({
|
|
105
99
|
type: 'select',
|
|
106
100
|
name: 'sample',
|
|
107
101
|
message: `Which sample would you like to use?`,
|
|
@@ -115,15 +109,15 @@ async function start() {
|
|
|
115
109
|
if (!sample) {
|
|
116
110
|
console.error();
|
|
117
111
|
console.error('Please specify which sample:');
|
|
118
|
-
console.error(` ${
|
|
112
|
+
console.error(` ${chalk.cyan(program.name())} --sample ${chalk.green('<name|github-url>')}`);
|
|
119
113
|
console.error();
|
|
120
114
|
console.error('For example:');
|
|
121
|
-
console.error(` ${
|
|
115
|
+
console.error(` ${chalk.cyan(program.name())} --sample ${chalk.green('hello-world')}`);
|
|
122
116
|
console.error();
|
|
123
|
-
console.error(`Run ${
|
|
117
|
+
console.error(`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`);
|
|
124
118
|
process.exit(1);
|
|
125
119
|
}
|
|
126
|
-
await
|
|
120
|
+
await createApp({
|
|
127
121
|
appPath: resolvedProjectPath,
|
|
128
122
|
useYarn: !!opts.useYarn,
|
|
129
123
|
gitInit: opts.gitInit,
|
|
@@ -132,15 +126,15 @@ async function start() {
|
|
|
132
126
|
samplePath: typeof opts.samplePath === 'string' ? opts.samplePath.trim() : undefined,
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
|
-
const update = (
|
|
129
|
+
const update = checkForUpdate(packageJson).catch(() => null);
|
|
136
130
|
async function notifyUpdate() {
|
|
137
131
|
try {
|
|
138
132
|
const res = await update;
|
|
139
133
|
if (res?.latest) {
|
|
140
134
|
console.log();
|
|
141
|
-
console.log(
|
|
135
|
+
console.log(chalk.yellow.bold('A new version of `@temporalio/create` is available!'));
|
|
142
136
|
console.log('You can update by running: ' +
|
|
143
|
-
|
|
137
|
+
chalk.cyan(opts.useYarn ? 'yarn global add @temporalio/create' : 'npm i -g @temporalio/create'));
|
|
144
138
|
console.log();
|
|
145
139
|
}
|
|
146
140
|
process.exit();
|
|
@@ -149,17 +143,17 @@ async function notifyUpdate() {
|
|
|
149
143
|
// ignore error
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
|
-
function run() {
|
|
146
|
+
export function run() {
|
|
153
147
|
start()
|
|
154
148
|
.then(notifyUpdate)
|
|
155
149
|
.catch(async (reason) => {
|
|
156
150
|
console.log();
|
|
157
151
|
console.log('Aborting installation.');
|
|
158
152
|
if (reason.command) {
|
|
159
|
-
console.log(` ${
|
|
153
|
+
console.log(` ${chalk.cyan(reason.command)} has failed.`);
|
|
160
154
|
}
|
|
161
155
|
else {
|
|
162
|
-
console.log(
|
|
156
|
+
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
|
|
163
157
|
console.log(reason);
|
|
164
158
|
}
|
|
165
159
|
console.log();
|
|
@@ -167,5 +161,4 @@ function run() {
|
|
|
167
161
|
process.exit(1);
|
|
168
162
|
});
|
|
169
163
|
}
|
|
170
|
-
exports.run = run;
|
|
171
164
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mIAAmI;AACnI,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAA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AG,EAAE,CAAC;QAEd,MAAM,YAAY,EAAE,CAAC;QAErB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/lib/pkg.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// ../package.json is outside of the TS project rootDir which causes TS to complain about this import.
|
|
7
|
-
// We do not want to change the rootDir because it messes up the output structure.
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
exports.default = package_json_1.default;
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
4
|
+
export default pkg;
|
|
12
5
|
//# sourceMappingURL=pkg.js.map
|
package/lib/pkg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../src/pkg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../src/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5F,eAAe,GAAwC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Create a Temporal project from template",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": "cli.js",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"build": "tsc --build",
|
|
9
10
|
"build.watch": "tsc --build --watch"
|
|
@@ -21,10 +22,9 @@
|
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"async-retry": "^1.3.3",
|
|
23
24
|
"chalk": "^2.4.2",
|
|
24
|
-
"chalk-
|
|
25
|
+
"chalk-template": "^0.2.0",
|
|
25
26
|
"commander": "^8.2.0",
|
|
26
27
|
"dedent": "^0.7.0",
|
|
27
|
-
"fs-extra": "^10.0.0",
|
|
28
28
|
"glob": "^7.2.0",
|
|
29
29
|
"got": "^10.7.0",
|
|
30
30
|
"prompts": "^2.4.1",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=14.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7706410cb67a1c92b9ae9eea1cac48e0dad4a8d1"
|
|
52
52
|
}
|