handoff-app 1.0.3 → 1.0.5
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/Changelog.md +16 -5
- package/README.md +93 -57
- package/dist/cli.js +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/init/index.d.ts +5 -0
- package/dist/commands/init/index.js +26 -0
- package/dist/create.d.ts +5 -0
- package/dist/create.js +293 -0
- package/dist/index.js +4 -1
- package/dist/transformers/plugins/ssr-render.js +4 -3
- package/dist/transformers/preview/component/api.js +3 -2
- package/dist/transformers/preview/component/builder.js +2 -1
- package/dist/transformers/utils/handlebars.js +3 -2
- package/package.json +1 -1
- package/src/app/components/Component/Preview.tsx +121 -121
- package/src/app/components/ComponentSearch.tsx +1 -1
- package/src/app/components/util/index.ts +17 -9
- package/src/app/pages/system/component/[component]/index.tsx +1 -1
- package/src/app/pages/system/index.tsx +2 -2
- package/src/app/pages/system/tokens/index.tsx +10 -10
- package/src/cli.ts +1 -1
- package/src/commands/index.ts +2 -0
- package/src/commands/init/index.ts +17 -0
- package/src/create.ts +302 -0
- package/src/index.ts +3 -0
- package/src/transformers/plugins/ssr-render.ts +3 -3
- package/src/transformers/preview/component/api.ts +1 -1
- package/src/transformers/preview/component/builder.ts +1 -1
- package/src/transformers/utils/handlebars.ts +2 -2
- package/templates/default/README.md.tpl +15 -0
- package/templates/default/components/button/Button.tsx.tpl +92 -0
- package/templates/default/components/button/button.js.tpl +62 -0
- package/templates/default/env.tpl +2 -0
- package/templates/default/gitignore.tpl +7 -0
- package/templates/default/handoff.config.js.tpl +181 -0
- package/templates/default/handoff.config.with-examples.js.tpl +182 -0
- package/templates/default/package.json.tpl +20 -0
- package/templates/default/tsconfig.json.tpl +24 -0
- package/dist/commands/platform/init.d.ts +0 -6
- package/dist/commands/platform/init.js +0 -231
- package/dist/commands/platform/login.d.ts +0 -6
- package/dist/commands/platform/login.js +0 -108
- package/dist/commands/platform/logout.d.ts +0 -6
- package/dist/commands/platform/logout.js +0 -88
- package/dist/commands/platform/pull.d.ts +0 -8
- package/dist/commands/platform/pull.js +0 -112
- package/dist/commands/platform/push.d.ts +0 -8
- package/dist/commands/platform/push.js +0 -428
- package/dist/platform/client.d.ts +0 -122
- package/dist/platform/client.js +0 -228
- package/dist/platform/credentials.d.ts +0 -40
- package/dist/platform/credentials.js +0 -91
- package/dist/platform/sync.d.ts +0 -68
- package/dist/platform/sync.js +0 -349
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const p = __importStar(require("@clack/prompts"));
|
|
39
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
-
const child_process_1 = require("child_process");
|
|
41
|
-
const client_1 = require("../../platform/client");
|
|
42
|
-
const credentials_1 = require("../../platform/credentials");
|
|
43
|
-
const DEFAULT_PLATFORM_URL = 'http://localhost:3000';
|
|
44
|
-
const command = {
|
|
45
|
-
command: 'platform:login',
|
|
46
|
-
describe: 'Log in to the Handoff platform',
|
|
47
|
-
builder: (yargs) => {
|
|
48
|
-
return yargs.option('url', {
|
|
49
|
-
type: 'string',
|
|
50
|
-
description: 'Platform URL',
|
|
51
|
-
default: process.env.HANDOFF_PLATFORM_URL || DEFAULT_PLATFORM_URL,
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
const baseUrl = (args.url || DEFAULT_PLATFORM_URL).replace(/\/+$/, '');
|
|
56
|
-
p.intro(chalk_1.default.bold('Handoff Platform Login'));
|
|
57
|
-
const spinner = p.spinner();
|
|
58
|
-
try {
|
|
59
|
-
spinner.start('Initiating authentication...');
|
|
60
|
-
const deviceCode = yield (0, client_1.createDeviceCode)(baseUrl);
|
|
61
|
-
spinner.stop('Authentication initiated.');
|
|
62
|
-
// Display the user code prominently
|
|
63
|
-
p.note([
|
|
64
|
-
`Your one-time code: ${chalk_1.default.bold.cyan(deviceCode.userCode)}`,
|
|
65
|
-
'',
|
|
66
|
-
`Open this URL to sign in:`,
|
|
67
|
-
chalk_1.default.underline(`${deviceCode.verificationUrl}`),
|
|
68
|
-
].join('\n'), 'Authentication');
|
|
69
|
-
// Try to open the browser automatically
|
|
70
|
-
openBrowser(deviceCode.verificationUrl);
|
|
71
|
-
spinner.start('Waiting for approval (this will open in your browser)...');
|
|
72
|
-
const result = yield (0, client_1.pollForToken)(baseUrl, deviceCode.deviceCode, deviceCode.interval, deviceCode.expiresIn);
|
|
73
|
-
spinner.stop('Authentication approved!');
|
|
74
|
-
// Store the token
|
|
75
|
-
(0, credentials_1.setToken)(baseUrl, result.token, {
|
|
76
|
-
name: result.user.name,
|
|
77
|
-
email: result.user.email,
|
|
78
|
-
});
|
|
79
|
-
p.note([
|
|
80
|
-
`Logged in as ${chalk_1.default.bold(result.user.name || result.user.email)}`,
|
|
81
|
-
`Platform: ${chalk_1.default.dim(baseUrl)}`,
|
|
82
|
-
].join('\n'), 'Success');
|
|
83
|
-
p.outro('You can now use platform:init to link a project.');
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
spinner.stop('Authentication failed.');
|
|
87
|
-
p.cancel(err.message || 'Login failed');
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
}),
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Attempt to open a URL in the default browser.
|
|
94
|
-
* Fails silently — the user can always copy/paste the URL.
|
|
95
|
-
*/
|
|
96
|
-
function openBrowser(url) {
|
|
97
|
-
const command = process.platform === 'darwin'
|
|
98
|
-
? `open "${url}"`
|
|
99
|
-
: process.platform === 'win32'
|
|
100
|
-
? `start "" "${url}"`
|
|
101
|
-
: `xdg-open "${url}"`;
|
|
102
|
-
(0, child_process_1.exec)(command, (err) => {
|
|
103
|
-
if (err) {
|
|
104
|
-
// Silently ignore — user will use the printed URL
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
exports.default = command;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const p = __importStar(require("@clack/prompts"));
|
|
39
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
-
const client_1 = require("../../platform/client");
|
|
41
|
-
const credentials_1 = require("../../platform/credentials");
|
|
42
|
-
const DEFAULT_PLATFORM_URL = 'http://localhost:3000';
|
|
43
|
-
const command = {
|
|
44
|
-
command: 'platform:logout',
|
|
45
|
-
describe: 'Log out from the Handoff platform',
|
|
46
|
-
builder: (yargs) => {
|
|
47
|
-
return yargs.option('url', {
|
|
48
|
-
type: 'string',
|
|
49
|
-
description: 'Platform URL',
|
|
50
|
-
default: process.env.HANDOFF_PLATFORM_URL || DEFAULT_PLATFORM_URL,
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
-
const baseUrl = (args.url || DEFAULT_PLATFORM_URL).replace(/\/+$/, '');
|
|
55
|
-
p.intro(chalk_1.default.bold('Handoff Platform Logout'));
|
|
56
|
-
const token = (0, credentials_1.getToken)(baseUrl);
|
|
57
|
-
if (!token) {
|
|
58
|
-
p.note(`Not currently logged in to ${chalk_1.default.dim(baseUrl)}.`, 'Info');
|
|
59
|
-
p.outro('Nothing to do.');
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const spinner = p.spinner();
|
|
63
|
-
try {
|
|
64
|
-
// Revoke the token on the server (best-effort)
|
|
65
|
-
spinner.start('Revoking token...');
|
|
66
|
-
try {
|
|
67
|
-
yield (0, client_1.revokeToken)(baseUrl, token);
|
|
68
|
-
}
|
|
69
|
-
catch (_a) {
|
|
70
|
-
// If the server is unreachable or the token is already invalid,
|
|
71
|
-
// still proceed to remove the local credential.
|
|
72
|
-
}
|
|
73
|
-
spinner.stop('Token revoked.');
|
|
74
|
-
// Remove from local credentials store
|
|
75
|
-
(0, credentials_1.removeToken)(baseUrl);
|
|
76
|
-
p.note(`Logged out from ${chalk_1.default.dim(baseUrl)}.`, 'Success');
|
|
77
|
-
p.outro('Local credentials removed.');
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
spinner.stop('Logout encountered an issue.');
|
|
81
|
-
// Still remove the local token even if revocation fails
|
|
82
|
-
(0, credentials_1.removeToken)(baseUrl);
|
|
83
|
-
p.note(`Local credentials removed, but server revocation may have failed.`, 'Warning');
|
|
84
|
-
p.outro('You are logged out locally.');
|
|
85
|
-
}
|
|
86
|
-
}),
|
|
87
|
-
};
|
|
88
|
-
exports.default = command;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const p = __importStar(require("@clack/prompts"));
|
|
39
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
-
const __1 = __importDefault(require("../../"));
|
|
41
|
-
const credentials_1 = require("../../platform/credentials");
|
|
42
|
-
const sync_1 = require("../../platform/sync");
|
|
43
|
-
const DEFAULT_PLATFORM_URL = 'http://localhost:3000';
|
|
44
|
-
const command = {
|
|
45
|
-
command: 'platform:pull',
|
|
46
|
-
describe: 'Pull project files from the Handoff platform',
|
|
47
|
-
builder: (yargs) => {
|
|
48
|
-
return yargs
|
|
49
|
-
.option('url', {
|
|
50
|
-
type: 'string',
|
|
51
|
-
description: 'Platform URL (overrides config)',
|
|
52
|
-
})
|
|
53
|
-
.option('force', {
|
|
54
|
-
alias: 'f',
|
|
55
|
-
type: 'boolean',
|
|
56
|
-
description: 'Overwrite all local files and delete orphaned files',
|
|
57
|
-
default: false,
|
|
58
|
-
})
|
|
59
|
-
.option('debug', {
|
|
60
|
-
alias: 'd',
|
|
61
|
-
type: 'boolean',
|
|
62
|
-
description: 'Enable debug mode',
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
handler: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
-
const handoff = new __1.default(args.debug, args.force);
|
|
67
|
-
const config = handoff.config;
|
|
68
|
-
const baseUrl = (args.url || (config === null || config === void 0 ? void 0 : config.platformUrl) || process.env.HANDOFF_PLATFORM_URL || DEFAULT_PLATFORM_URL).replace(/\/+$/, '');
|
|
69
|
-
const projectId = config === null || config === void 0 ? void 0 : config.platformProjectId;
|
|
70
|
-
p.intro(chalk_1.default.bold('Handoff Platform Pull'));
|
|
71
|
-
if (!projectId) {
|
|
72
|
-
p.cancel(`No project linked. Run ${chalk_1.default.cyan('handoff-app platform:init')} first.`);
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
const token = (0, credentials_1.getToken)(baseUrl);
|
|
76
|
-
if (!token) {
|
|
77
|
-
p.cancel(`Not logged in to ${baseUrl}. Run ${chalk_1.default.cyan('handoff-app platform:login')} first.`);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
const spinner = p.spinner();
|
|
81
|
-
try {
|
|
82
|
-
spinner.start('Pulling from platform...');
|
|
83
|
-
const result = yield (0, sync_1.pullProject)(baseUrl, token, projectId, handoff.workingPath, {
|
|
84
|
-
force: args.force,
|
|
85
|
-
onProgress: (msg) => spinner.message(msg),
|
|
86
|
-
});
|
|
87
|
-
spinner.stop('Pull complete.');
|
|
88
|
-
const summary = [
|
|
89
|
-
`Downloaded: ${chalk_1.default.green(String(result.downloaded.length))} file(s)`,
|
|
90
|
-
`Unchanged: ${chalk_1.default.dim(String(result.unchanged.length))} file(s)`,
|
|
91
|
-
];
|
|
92
|
-
if (result.deleted.length > 0) {
|
|
93
|
-
summary.push(`Deleted: ${chalk_1.default.red(String(result.deleted.length))} file(s)`);
|
|
94
|
-
}
|
|
95
|
-
summary.push(`Sync version: ${chalk_1.default.cyan(String(result.version))}`);
|
|
96
|
-
p.note(summary.join('\n'), 'Pull Summary');
|
|
97
|
-
if (result.downloaded.length > 0) {
|
|
98
|
-
p.log.info(chalk_1.default.dim('Downloaded files:'));
|
|
99
|
-
for (const file of result.downloaded) {
|
|
100
|
-
p.log.info(chalk_1.default.dim(` + ${file}`));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
p.outro('Local project is up to date.');
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
spinner.stop('Pull failed.');
|
|
107
|
-
p.cancel(err.message || 'Pull failed');
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
};
|
|
112
|
-
exports.default = command;
|